public void ExecuteAndWait(string operation, string message,
                                   AsyncWaitCallback callback, object state)
        {
            if (!_processing)
            {
                _aborted            = false;
                _processing         = true;
                _executionState     = state;
                _executionException = null;
                _executionResult    = null;
                _callback           = callback;

                _view = new AsyncWaitDialog();
                _view.AbortClicked += OnAbortClicked;
                _view.Title         = operation;
                _view.StatusMessage = message;

                // Start the thread
                _executionThread      = new Thread(OnExecuteCallback);
                _executionThread.Name = "AsyncWaitExecute";
                _executionThread.Start();

                // Delay to show view
                for (int index = 0; index < 5 && _processing; index++)
                {
                    Thread.Sleep(100);
                }

                if (_processing)
                {
                    _view.Show(MainController.View.Handler);
                }
            }
        }
 private void CloseView()
 {
     if (_view != null)
     {
         Control viewControl = _view as Control;
         if (viewControl.InvokeRequired)
         {
             viewControl.BeginInvoke(new ThreadStart(CloseView));
         }
         else
         {
             _view.Close();
             _view = null;
         }
     }
 }