You are already doing this almost right. BackgroundWorker has a built-in mechanism for reporting progress already.
public Form1() { bw1.WorkerReportsProgress = true; bw1.ProgressChanged += bw1_ProgressChanged; bw1.DoWork += bw1_DoWork; bw1.RunWorkerAsync(); } private void bw1_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; while (workNotDone) {
If you, of course, are not trying to animate the progress bar without reporting any progress, then you should probably just use the Marquee type, which will automatically scroll through the progress bar without any action. Or just use the background thread with Thread.Sleep() .
source share