Non modal "status" form
- by David Jenings
At the beginning of a section of C# code that could take several seconds to complete, I'd like to display a non modal form with a label that just says, "Please wait..."
WaitForm myWaitForm = null;
try
{
// if conditions suggest process will take awhile
myWaitForm = new WaitForm();
myWaitForm.Show();
// do stuff
}
finally
{
if (myWaitForm != null)
{
myWaitForm.Hide();
myWaitForm.Dispose();
myWaitForm = null;
}
}
The problem: the WaitForm doesn't completely display before the rest of the code ties up the thread. So I only see the frame of the form. In Delphi (my old stomping ground) I would call Application.ProcessMessages after the Show() Is there an equivalent in C#? Is there a canned "status" form that I can use in situations like this? Is there a better way to approach this?
Thanks in advance.
David Jennings