PC Review


Reply
Thread Tools Rate Thread

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

 
 
trint
Guest
Posts: n/a
 
      15th Mar 2005
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

 
Reply With Quote
 
 
 
 
Morten Wennevik
Guest
Posts: n/a
 
      15th Mar 2005
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.

On 15 Mar 2005 06:05:05 -0800, trint <(E-Mail Removed)> wrote:

> 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
>




--
Happy Coding!
Morten Wennevik [C# MVP]
 
Reply With Quote
 
Peter Jausovec
Guest
Posts: n/a
 
      15th Mar 2005
Hi Trinity,

Run this large function in a new thread.

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"trint" <(E-Mail Removed)> je napisal v sporocilo
news:(E-Mail Removed) ...
> 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
>



 
Reply With Quote
 
trint
Guest
Posts: n/a
 
      15th Mar 2005
Thanks, I will try putting in a separate thread.
Trint

 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      15th Mar 2005
hi,

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

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



"trint" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks, I will try putting in a separate thread.
> Trint
>



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      15th Mar 2005
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us>> wrote:
> Just be aware that you should access the UI from the worker thread.


Just to correct Ignacio's typo:

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

See http://www.pobox.com/~skeet/csharp/winforms.shtml for more
information.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Ajay Kalra
Guest
Posts: n/a
 
      15th Mar 2005
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.

-----------
Ajay Kalra
(E-Mail Removed)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My Screen Turns all white blackfire4465@hotmail.com Computer Hardware 5 26th Mar 2006 10:36 PM
White turns Gray Someguy Windows XP MovieMaker 6 9th May 2005 09:59 PM
signature turns white when replying =?Utf-8?B?Y2hhcnJpczk5?= Microsoft Outlook Discussion 0 17th Nov 2004 02:14 PM
LDC screen turns white tommycommy Computer Hardware 2 27th Mar 2004 11:32 AM
Screen turns white with WMM. Bill Windows XP MovieMaker 2 21st Mar 2004 08:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:03 PM.