Beispiel #1
0
 private void CancelFormButton_Click(object sender, EventArgs e)
 {
     AddStatusText("Attempting to cancel...");
     CancelFormButton.Enabled = false;
     FixBackgroundWorker.CancelAsync();
     cancellationTokenSource.Cancel();
 }
Beispiel #2
0
 private void ReportException(int progressPercent, Exception ex)
 {
     if (cancellationTokenSource.IsCancellationRequested)
     {
         return;
     }
     FixBackgroundWorker.ReportProgress(progressPercent, "ERROR: " + ex.Message);
     ErrorsOccurred = true;
 }
Beispiel #3
0
 private void FixBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int i     = 0;
         int total = Actions.Count();
         foreach (var action in Actions)
         {
             if (FixBackgroundWorker.CancellationPending)
             {
                 e.Cancel = true;
                 return;
             }
             if (action.HasSql())
             {
                 i++;
             }
             else
             {
                 total--;
             }
             var progressPercent = i * 100 / total;
             FixBackgroundWorker.ReportProgress(progressPercent, action.GetStatus());
             try
             {
                 IndexDataProvider.ExecuteAction(action, cancellationTokenSource);
             }
             catch (AggregateException ex)
             {
                 foreach (var ex2 in ex.InnerExceptions)
                 {
                     ReportException(progressPercent, ex2);
                 }
             }
             catch (Exception ex)
             {
                 ReportException(progressPercent, ex);
             }
             FixBackgroundWorker.ReportProgress(progressPercent);
         }
     }
     catch (Exception ex)
     {
         FixBackgroundWorker.ReportProgress(0, "ERROR: " + ex.Message);
         ErrorsOccurred = true;
     }
 }
Beispiel #4
0
 private void FixProgressDialog_Shown(object sender, EventArgs e)
 {
     FixBackgroundWorker.RunWorkerAsync();
     startedOn = DateTime.Now;
     clockTimer.Start();
 }