예제 #1
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Debug.WriteLine("BackgroundWorker_RunWorkerCompleted " + Thread.CurrentThread.ManagedThreadId);

            bool      isCancelled = e.Cancelled;
            Exception ex          = e.Error;
            object    result      = null;

            // The property e.Result throws an exception if requested when Error is set or Cancelled is true
            if (ex == null && !isCancelled)
            {
                result = e.Result;
            }

            _result = new ProgressDialogResult(result, isCancelled, ex);

            if (AutoClose || _result.Exception != null)
            {
                Close();
            }
            else
            {
                cancelButton.Text    = "&Close";
                cancelButton.Enabled = true;
                cancelButton.Focus();
            }
        }
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Debug.WriteLine("BackgroundWorker_RunWorkerCompleted " + Thread.CurrentThread.ManagedThreadId);
            bool      cancelled = e.Cancelled;
            Exception error     = e.Error;
            object    value     = null;

            if (error == null && !cancelled)
            {
                value = e.Result;
            }
            this._result = new ProgressDialogResult(value, cancelled, error);
            if (this.AutoClose || this._result.Exception != null)
            {
                base.Close();
            }
            else
            {
                this.cancelButton.Text    = "&Close";
                this.cancelButton.Enabled = true;
                this.cancelButton.Focus();
            }
        }
 private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     Debug.WriteLine("BackgroundWorker_RunWorkerCompleted " + Thread.CurrentThread.ManagedThreadId);
     bool cancelled = e.Cancelled;
     Exception error = e.Error;
     object value = null;
     if (error == null && !cancelled)
     {
         value = e.Result;
     }
     this._result = new ProgressDialogResult(value, cancelled, error);
     if (this.AutoClose || this._result.Exception != null)
     {
         base.Close();
     }
     else
     {
         this.cancelButton.Text = "&Close";
         this.cancelButton.Enabled = true;
         this.cancelButton.Focus();
     }
 }