private static void DisplayWaitingForm() { if (_waitForm != null) { if (!_waitForm.IsDisposed) { _waitForm.Dispose(); } _waitForm = null; _isVisible = false; } try { if (_isAborted) { return; } _waitForm = new frmWait(); if (_cancelable) { _waitForm.btnCancel.Enabled = true; _waitForm.btnCancel.Click += new EventHandler(btnCancel_Click); } try { _isVisible = true; _waitForm.Show(); _waitForm.Focus(); while (!_isAborted) { System.Threading.Thread.Sleep(15); _waitForm.lblMessage.Text = _waitingState; Application.DoEvents(); _waitForm.lblMessage.Text = _waitingState; } _isVisible = false; } finally { FreeWaitingForm(); } } finally { _isVisible = false; } }