Skip to main content

Is there a way to display a form for about 5 seconds and then return to the program? What I am basically trying to do is to display a background form and then display another form on top of it (I do not wish to hide the background form until the user triggers an event on the second form). I therefore want to invoke the second from within my background form without closing or hiding the background form.

 

I did this once with a Visual Basic form as follows:

System.Threading.Thread.CurrentThread.Sleep(5000)

 

But I do not know if there is anything remotely similar in Managed COBOL.

Is there a way to display a form for about 5 seconds and then return to the program? What I am basically trying to do is to display a background form and then display another form on top of it (I do not wish to hide the background form until the user triggers an event on the second form). I therefore want to invoke the second from within my background form without closing or hiding the background form.

 

I did this once with a Visual Basic form as follows:

System.Threading.Thread.CurrentThread.Sleep(5000)

 

But I do not know if there is anything remotely similar in Managed COBOL.

Most .NET Framework classes and methods are available in Visual COBOL although the syntax may be a bit different.

You can invoke the Sleep method:

       invoke type System.Threading.Thread::Sleep(5000)

or if you have VC 5.0 await can be used as follows to accomplish the same basic functionality.

       invoke await type System.Threading.Tasks.Task::Delay(5000)

If you use await then you need to mark the current method as async or async-void.

       Example:
            method-id buttonRead_Click final private async-void.


Most .NET Framework classes and methods are available in Visual COBOL although the syntax may be a bit different.

You can invoke the Sleep method:

       invoke type System.Threading.Thread::Sleep(5000)

or if you have VC 5.0 await can be used as follows to accomplish the same basic functionality.

       invoke await type System.Threading.Tasks.Task::Delay(5000)

If you use await then you need to mark the current method as async or async-void.

       Example:
            method-id buttonRead_Click final private async-void.

This semi- works. What I have is the following:

 

method-id TPS0010Form_Load final private.
procedure division using by value sender as object e as type System.EventArgs.

set txtLOGON-SIGN-ON::BackColor to type Color::White.
set txtLOGON-SIGN-ON::ForeColor to type Color::Black.
invoke type System.Threading.Thread::Sleep(5000).


end method.

 

What this code does is that it waits for about 5 seconds and then displays the screen. I would like to do the opposite if it is possible. I want to display the screen and then return to the program automatically after 5 seconds (almost like a splash screen).


This semi- works. What I have is the following:

 

method-id TPS0010Form_Load final private.
procedure division using by value sender as object e as type System.EventArgs.

set txtLOGON-SIGN-ON::BackColor to type Color::White.
set txtLOGON-SIGN-ON::ForeColor to type Color::Black.
invoke type System.Threading.Thread::Sleep(5000).


end method.

 

What this code does is that it waits for about 5 seconds and then displays the screen. I would like to do the opposite if it is possible. I want to display the screen and then return to the program automatically after 5 seconds (almost like a splash screen).

You could place the Sleep function in a different event handler like, Activate or Shown perhaps?

You could also place it after the Form.Show method invocation in the original form code:

Something like:

           declare newform = new Form2
           invoke newform::Show
           invoke type System.Threading.Thread::Sleep(5000).
           invoke newform::Close

The Sleep function will make the UI unresponsive and may not be the best choice for this functionality. 

Somebody else may have a better solution for you here like perhaps setting a timer, etc.?


You could place the Sleep function in a different event handler like, Activate or Shown perhaps?

You could also place it after the Form.Show method invocation in the original form code:

Something like:

           declare newform = new Form2
           invoke newform::Show
           invoke type System.Threading.Thread::Sleep(5000).
           invoke newform::Close

The Sleep function will make the UI unresponsive and may not be the best choice for this functionality. 

Somebody else may have a better solution for you here like perhaps setting a timer, etc.?

This worked for what I want to achieve, thank you! But if anyone else has ideas on setting the screen to time off, please let me know. I am trying to see if there is a better way.