busy threads
-
I have a process that is executing so fast that the ui can't keep up. there is a function that is called as fast as the next file is copied from an old location to a new location. I am keeping a record of this in a textbox. however, this is happening so fast that the form surface is greyed out kinda and not showing the control's contents untill the process of copying files has completed. Worker threads shouldn't be used to manipulate ui controls, and I've tried using a timer, and I've tried delaying threading. I've had no luck. Even invalidating the control every time a new item should be painted doesn't work. I am very open to any help or suggestions. Thank you, Stephen
-
I have a process that is executing so fast that the ui can't keep up. there is a function that is called as fast as the next file is copied from an old location to a new location. I am keeping a record of this in a textbox. however, this is happening so fast that the form surface is greyed out kinda and not showing the control's contents untill the process of copying files has completed. Worker threads shouldn't be used to manipulate ui controls, and I've tried using a timer, and I've tried delaying threading. I've had no luck. Even invalidating the control every time a new item should be painted doesn't work. I am very open to any help or suggestions. Thank you, Stephen
-
problem solved. if anybody else ever has this problem, this is what I used: System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(15)); form2.Invalidate(); form2.Refresh(); System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(20));
You do realize that you're slowing down the copying also, don't you? The best way is to have a worker thread to the copying and report progress to the UI using
BeginInvoke
orInvoke
. See www.codeproject.com/csharp/begininvoke.asp[^] for more details. Regards Senthil _____________________________ My Blog | My Articles | WinMacro -
problem solved. if anybody else ever has this problem, this is what I used: System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(15)); form2.Invalidate(); form2.Refresh(); System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(20));
You could also replace all this code with a simple call to:
Application.DoEvents();
This will let the UI respond to WM_PAINT messages and update the screen. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome