Winform progress bar with loading style
progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; BackgroundWorker bgw bgw.WorkerSupportsCancellation = true; bgw.DoWork += new DoWorkEventHandler(bgw_DoWork); protected void bgw_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (!worker.CancellationPending) { if (IsHidden) // auto property { waitingForm.TopLevel = false; // wait form which only includes progress bar with Marquee style. waitingForm.TopMost = false; } else { waitingForm.TopLevel = true; waitingForm.TopMost = true; waitingForm.Focus(); waitingForm.Refresh(); } } }