bool bContinue = true;public frmProgressBar(string Message){ InitializeComponent(); this.ShowInTaskbar = false; lblMessage.Text = Message ; backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork); backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler (backgroundWorker_RunWorkerCompleted);}//This is called when my main window is resized event us firedprivate void setWindowStateAccordingToMainForm(FormWindowState State){ if (this.InvokeRequired) { setWindowState d = new setWindowState(setWindowStateAccordingToMainForm); this.Invoke(d, new object[] { State }); } else { if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal)) { if (!this.IsDisposed) { WindowState = FormWindowState.Maximized; Show(); } } else if (State == FormWindowState.Minimized) { if (!this.IsDisposed) { WindowState = FormWindowState.Minimized; Hide(); } } }}void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ this.Close(); this.Dispose();}void backgroundWorker_DoWork(object sender, DoWorkEventArgs e){ while (bContinue) { }}