private static void FreeWaitingForm()
 {
     _waitingState = "";
     _isVisible    = false;
     if (_waitForm == null)
     {
         return;
     }
     _waitForm.Hide();
     if (!_waitForm.IsDisposed)
     {
         _waitForm.FormIsClosing();
         _waitForm.Dispose();
     }
     _waitForm = null;
 }
        private static void DisplayWaitingForm()
        {
            if (_waitForm != null)
            {
                if (!_waitForm.IsDisposed)
                {
                    _waitForm.FormIsClosing();
                    _waitForm.Dispose();
                }
                _waitForm  = null;
                _isVisible = false;
            }
            try
            {
                if (_isAborted)
                {
                    return;
                }

                _waitForm = new frmPleaseWait();
                if (_cancelable)
                {
                    _waitForm.btnCancel.Enabled = true;
                    _waitForm.btnCancel.Click  += new EventHandler(btnCancel_Click);
                }
                try
                {
                    _isVisible = true;
                    _waitForm.Show();
                    while (!_isAborted)
                    {
                        System.Threading.Thread.Sleep(10);
                        _waitForm.lblMessage.Text = _waitingState;
                        Application.DoEvents();
                        _waitForm.lblMessage.Text = _waitingState;
                    }
                }
                finally
                {
                    FreeWaitingForm();
                }
            }
            finally
            {
            }
        }