title: The right way to implement a progressbar in C#
body: <p>I'm learning winforms and I have set myself a simple goal of making a progressbar that goes from empty to full. Here's my misshapen attempt:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      static BackgroundWorker bw = new BackgroundWorker();
  
      public Form1()
      {
          InitializeComponent();
          bw.DoWork += bw_DoWork;
          bw.RunWorkerAsync();
      }
  
      void bw_DoWork(object sender, DoWorkEventArgs e)
      {
          for(int i=0; i&lt;100; ++i)
          {
              progressBar1.PerformStep();
              Thread.Sleep(10);
          }
      }
  }
  </code></pre>
  
  <p>I'm pretty sure that the <code>Thread.Sleep()</code> is reprehensible. How do I avoid it here? </p>