Steve411 wrote:
I'd use Sven's example.. Here's one, also:
internal void UpdateStatusBar(bool True, bool SwitchDefault)
{
if(SwitchDefault == true)
{ThePostDetails.SwitchToDefault();}else{}
if(True == true)
{
this.Update();
for(int i=ProgressNotification.Minimum; i <= ProgressNotification.Maximum; i++)
{
Thread.Sleep(10);
ProgressNotification.PerformStep();
UpdateBar.Panels[1].Text = ProgressNotification.Value.ToString();
}
}
if(True == false)
{
this.Update();
ProgressNotification.Value = 0;
UpdateBar.Panels[1].Text = ProgressNotification.Value.ToString();
}
this.Update();
}
|
The above sample makes my skin crawl --
never use a Thread sleep on a UI thread. The UI thread should do as little work as possible so that the application can remain responsive.