private void UploadWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     IList<BlackBoxReport> reports = (IList<BlackBoxReport>)e.Argument;
        SteppedProgressManager overallProgress = new SteppedProgressManager();
        for (int i = 0; i < reports.Count; ++i)
        {
     ProgressManager reportProgress = new ProgressManager();
     overallProgress.Steps.Add(new SteppedProgressManagerStep(reportProgress,
      1.0f / reports.Count));
     BlackBoxReportUploader uploader = new BlackBoxReportUploader(reports[i]);
     UploadWorker.ReportProgress((int)(overallProgress.Progress * 100),
      S._("Checking for status of report {0}...", reports[i].Name));
     if (!uploader.IsNew)
      continue;
     if (UploadWorker.CancellationPending)
      throw new OperationCanceledException();
     UploadWorker.ReportProgress((int)(overallProgress.Progress * 100),
      S._("Compressing Report {0}: {1:#0.00%}", reports[i].Name, 0));
     uploader.Submit(delegate(object from, EraserProgressChangedEventArgs e2)
      {
       reportProgress.Completed = (int)(e2.Progress.Progress * reportProgress.Total);
       SteppedProgressManager reportSteps = (SteppedProgressManager)e2.Progress;
       int step = reportSteps.Steps.IndexOf(reportSteps.CurrentStep);
       UploadWorker.ReportProgress((int)overallProgress.Progress,
        step == 0 ?
     S._("Compressing Report {0}: {1:#0.00%}",
      reports[i].Name, reportSteps.Progress) :
     S._("Uploading Report {0}: {1:#0.00%}",
      reports[i].Name, reportSteps.Progress));
       if (UploadWorker.CancellationPending)
        throw new OperationCanceledException();
      });
        }
 }
 private void UploadWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     IList<BlackBoxReport> reports = (IList<BlackBoxReport>)e.Argument;
        for (int i = 0; i < reports.Count; ++i)
        {
     int progressPerReport = 100 / reports.Count;
     int baseProgress = i * progressPerReport;
     int stepsPerReport = 2;
     BlackBoxReportUploader uploader = new BlackBoxReportUploader(reports[i]);
     UploadWorker.ReportProgress(baseProgress,
      S._("Checking for status of report {0}...", reports[i].Name));
     if (!uploader.ReportIsNew())
      continue;
     if (UploadWorker.CancellationPending)
      throw new OperationCanceledException();
     UploadWorker.ReportProgress(baseProgress,
      S._("Compressing Report {0}: {1}%", reports[i].Name, 0));
     uploader.Compress(delegate(object from, ProgressChangedEventArgs progress)
      {
       UploadWorker.ReportProgress(baseProgress +
        progress.ProgressPercentage * progressPerReport / 100 / stepsPerReport,
        S._("Compressing Report {0}: {1}%",
     reports[i].Name, progress.ProgressPercentage));
       if (UploadWorker.CancellationPending)
        throw new OperationCanceledException();
      });
     UploadWorker.ReportProgress(baseProgress + progressPerReport / 2,
      S._("Uploading Report {0}: {1}%", reports[i].Name, 0));
     uploader.Upload(delegate(object from, ProgressChangedEventArgs progress)
      {
       UploadWorker.ReportProgress(baseProgress + progressPerReport / stepsPerReport +
        progress.ProgressPercentage * progressPerReport / 100 / stepsPerReport,
        S._("Uploading Report {0}: {1}%",
     reports[i].Name, progress.ProgressPercentage));
       if (UploadWorker.CancellationPending)
        throw new OperationCanceledException();
      });
        }
 }