Form turns white and ugly...

Audax321

Regular
Joined
May 4, 2002
Messages
90
I have my program displaying a label (just says Please wait... blah blah blah) while some code is being run (it takes a while). Well, if my form loses focus and then gains focus... it turns all white until the code is done executing. Since this could cause the user to think the application is crashing, is there anyway to prevent this. This happened in VB6 too but wasn't as much of a problem with programs I wrote under that.

Thanks... :)
 
Are you in a loop? If you are, you could try a few things.

For one, you could put Application.DoEvents() at the end of your loop
(right before the 'Loop' part). Another way is to put Me.Refresh() at
the end of the loop.

If the code is in some place where you don't have the source, I don't know.
You could look into threading, but there may be an easier way.
 
Thanks.... the me.refresh() didn't work, but the Application.DoEvents() worked great. I was trying to invoke that as just plain DoEvents earlier... completely forgot how to call that in .net. :)
 
Ideally, you'd run your intensive code in another thread anyway. DoEvents isn't really necessary.
 
Back
Top