title: Thread sleeping in a BackgroundWorker
body: <p>I wrote a simple app that adds 100000 lines of "Hello World" to a list using a BackgroundWorker.</p>
  
  <p>Below is the code of the work that my backgroundworker is doing in a separate thread:</p>
  
  <pre><code>    private void BgWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
      {
          int min = 0;
  
          foreach (var hw in hwList)
          {
              //new ManualResetEvent(false).WaitOne(1);
              Thread.Sleep(1);
              int progress = Convert.ToInt32((Double)min / hwList.Count * 100);
              min++;
              bgWorker.ReportProgress(progress);
          }
      }
  
      // Updating the progress
      private void BgWorkerOnProgressChanged(object sender, ProgressChangedEventArgs progressChangedEventArgs)
      {
          ProgressBar.Value = progressChangedEventArgs.ProgressPercentage;
      }
  </code></pre>
  
  <p>All is working fine, except that if I remove the <strong>Thread.Sleep(1)</strong> the <strong>BackgroundWorker</strong> doesn't report the progress anymore. (I suppose it needs some time). Suspending the thread for 1 ms actually makes the <strong>BackgroundWorker</strong> report the progress but it's very slow.</p>
  
  <p>My question is, is there a way I can get rid of thread sleeping but at the same time making the <strong>BackgroundWorker</strong> report the progress correctly?</p>
  
  <p>From my understanding, suspending the <strong>BackgroundWorker</strong> is inevitable, since the thread needs some time to perform the task, but I'm wondering if there's a workaround.</p>