Start a method after form shown on screen

  • Thread starter Thread starter Smokey Grindel
  • Start date Start date
S

Smokey Grindel

Where or what is the proper way to get a procedure to start after the form
is shown on the screen? I figured out if you put it in Load it will start
before the form is shown and the form will not show until the procedure is
complete... so whats the best way to get something to start after the form
is loaded and visible? thanks!
 
ah awesome, the activated one I was staying away from because every time it
got focus it reactivated the form it seemed like...
 
ah awesome, the activated one I was staying away from because every time it
got focus it reactivated the form it seemed like...

Hi Smokey,

You could use a BackgroundWorker class. See help on
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_fxmclictl/
html/5b56e2aa-dc05-444f-930c-2d7b23f9ad5b.htm

Or alternatively, you could start a timer at the end of the form Load
event and perform your job the first time the timer tick is called.
This is not a true background solution though.

JB
 
Smokey,

If I need to use the Activated method I usually create a boolean value so not to
use it from keep firing:

Example:

Dim blnHasFired As Boolean = False

Then use something like this:

If blnHasFired = False Then
' Do Something Here
blnHasFired = True
Exit Sub
End If
 
Smokey Grindel said:
Where or what is the proper way to get a procedure to start after the form
is shown on the screen? I figured out if you put it in Load it will start
before the form is shown and the form will not show until the procedure is
complete... so whats the best way to get something to start after the form
is loaded and visible? thanks!

My (probably rough!) solution to this is to force the form to show before
doing anything...

So in form_load, I put

{
Form1.Show();
Application.DoEvents();

Do stuff.... ;
}
 
Back
Top