Re: Simple WinForm ( Not Responding ) Refesh Issue C# 2.0



On Thu, 13 Sep 2007 21:06:55 +0200, OZI <sql_agentman@xxxxxxxxxxx> wrote:


for (int x = 0; x < progressBar1.Maximum ; x++)

{

progressBar1.Increment(1);

System.Threading.Thread.Sleep(1000);

this.Refresh();

}


Telling the window to refresh itself isn't helping much since you don't give it any time to handle user interaction. If you add Application.DoEvents() after Refresh() (or instead of as you don't need to refresh to update the progress bar) you should see a noticeable difference. Alternately go the BackgroundWorker way (see the code sample in my other reply)..



--
Happy coding!
Morten Wennevik [C# MVP]
.



Relevant Pages