[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 780
  • Last Modified:

VB.Net - Yes/No MessageBox

Good Day Experts!

I have a Yes/No DialogResult MessageBox.  When User answers Yes to process records,  processing starts but then part of the MessageBox can still be seen.  Then eventually where the MessageBox shows the area turns white. Then the area where the MessageBox had turned white goes away and the controls behind it are white.  I do have the cursor changing to the hourglass.

Any ideas what might be going wrong?

Thanks,
jimbo99999
0
Jimbo99999
Asked:
Jimbo99999
  • 5
  • 3
  • 2
2 Solutions
 
CodeCruiserCommented:
Just call Application.DoEvents after Yes click and probably periodically during processing as well. This will force the window and controls to invalidate/paint themselves correctly.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I agree with CodeCruiser.

Your description indicates that you have a lengthy process running, which means it should probably be put into a different thread so that the main UI can continue to be responsive while it works.  Take a look at using the BackgroundWorker() control...
0
 
Jimbo99999Author Commented:
The Application.DoEvents has cleaned up the situation.  But now my hourglass has gone away before the end of processing message.   Perhaps I need to reset the cursor to the hourglass each time I do Application.DoEvents?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
CodeCruiserCommented:
Never experienced that. Call DoEvents before setting the cursor.
0
 
Jimbo99999Author Commented:
CodeCruiser...how do I determine where to periodically put the DoEvents in my code? For some reason this last time I ran the report the UI turned white about 5minutes prior to completion.  I go out to the database to run a S/P 2 times.  Should I do the DoEvent and hourglass setting before and after the S/P calls?

Thanks,
jimbo99999
0
 
CodeCruiserCommented:
Yes.
0
 
Jimbo99999Author Commented:
Excellent...no white UI tha tlast time.

Thanks,
jimbo99999
0
 
Jimbo99999Author Commented:
Another good one to put in the toolbox as I continue the learning process.

Thanks again,
jimbo99999
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"the UI turned white about 5 minutes prior to completion"

If your process is going to take 5 minutes then you should DEFINITELY be putting it into a background thread with the BackgroundWorker() control.  

Database operations like that are often blocking calls which means that DoEvents() won't fully fix the problem.  It may allow the form to refresh immediately before the call, but during the database operation the form will be unresponsive and won't repaint.  If the user clicks on the form, or attempts to move it, then it will probably "white out".  This would also occur if they switched to another application and then switched back.

Putting the work in the background thread will keep the form responsive and prevent white outs.  You would NOT need DoEvents() at all then...
0
 
Jimbo99999Author Commented:
I am currently looking for information on your suggestion.  All of this is still new to me so I appreciate the feedback as I continue my learning process.

jimbo99999
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now