示例#1
0
 private void ReportException(int progressPercent, Exception ex)
 {
     if (cancellationTokenSource.IsCancellationRequested)
     {
         return;
     }
     FixBackgroundWorker.ReportProgress(progressPercent, "ERROR: " + ex.Message);
     ErrorsOccurred = true;
 }
示例#2
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;
     }
 }