G
Guest
Hey guys,
I'm trying to update a progress bar for a long running process that updates
quite frequently. I also would like the GUI to remain responsive to
resizing/moving/repainting, etc.
When I use the below methods in a background worker thread the GUI doesn't
remain very responsive. Is it because the progress bar is being updated very
frequently? If I have a real process running that updates just as fast, what
can I do to keep the GUI running smoothly?
Thanks,
-Flack
======================================
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 50000; i++)
{
backgroundWorker1.ReportProgress((int)((i / 50000.0) * 100.0));
}
}
private void backgroundWorker1_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void backgroundWorker1_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Done");
}
I'm trying to update a progress bar for a long running process that updates
quite frequently. I also would like the GUI to remain responsive to
resizing/moving/repainting, etc.
When I use the below methods in a background worker thread the GUI doesn't
remain very responsive. Is it because the progress bar is being updated very
frequently? If I have a real process running that updates just as fast, what
can I do to keep the GUI running smoothly?
Thanks,
-Flack
======================================
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i < 50000; i++)
{
backgroundWorker1.ReportProgress((int)((i / 50000.0) * 100.0));
}
}
private void backgroundWorker1_ProgressChanged(object sender,
ProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage;
}
private void backgroundWorker1_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Done");
}