title: progress bar using backgroundworker
body: <p>There have been a bunch of questions on how to implement a progress bar and I believe I have been through all of them and I still don't know why my progress bar won't work.</p>
  
  <p>Well, it seems to work only after the operation is done, which is of course not what I want. I want the progress bar to work as the main operation is doing its thing. </p>
  
  <p>My code is pretty long and painful so I'm going to simplify it to make it as basic as possible.</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
    backgroundWorker1.RunWorkerAsync();
    //Main UI Operation
  }
  
  private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
  {
   for (int i = 1; i &lt;= 100; i++)
    {
     // Wait 100 milliseconds.
     Thread.Sleep(100);
     // Report progress.
     backgroundWorker1.ReportProgress(i);     }
    }
  
  private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs        e)
    {
     progressBar1.Value = e.ProgressPercentage;
    }
  </code></pre>
  
  <p>Like I said, I only see the progress bar start after my main UI operation. </p>
  
  <p>WorkerReportsProgress is set to True.
  Minimum and Maximum are 0 and 100 respectively.</p>
  
  <p>I feel like this might be a lack of understanding on Threads.</p>