When app runs, window turns white!!???

  • Thread starter Thread starter trint
  • Start date Start date
T

trint

This application has a for loop that calls a large function:
"foreach (string invoice in listBox2.Items)"

and causes the window to turn white and loose view of all control.
How can I keep this from happening?
Thanks,
Trint
 
Hi Trint,

If I understand your problem correctly the whiteness is caused by a busy
application not having the time to repaint the controls. To solve this
you could handle the foreach loop in a different thread, keeping the GUI
thread up to speed, or call Application.DoEvents() ever so often inside
your loop to handle any waiting events.
 
hi,

Just be aware that you should access the UI from the worker thread.

cheers,
 
As others have pointed out, using a separate worker thread will free up
your main UI thread and your application will become responsive.

I have found the following article by Jason Clark to be helpful in
Windows Forms:

http://msdn.microsoft.com/msdnmag/issues/04/01/NET/

He shows how to use ThreadPool class in a WinForm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top