title: Update GUI using BackgroundWorker
body: <p>I've been searching and found that a good way to perform background work and update the GUI is using background workers. However, doing this (stupid) little task (counting from 1 to 10000) it doesn't update the label content but prints to the debug! (This is just a spike solution for another project of course...)</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      BackgroundWorker bw = new BackgroundWorker();
  
      public MainWindow()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
  
          bw.DoWork += new DoWorkEventHandler(bw_DoWork);
          bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
          bw.WorkerReportsProgress = true;
          bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
          bw.RunWorkerAsync();
  
      }
  
      void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      {
          MessageBox.Show("DONE");
  
      }
  
      void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
      {
          label1.Content = "going here: "+e.ProgressPercentage;
          Debug.WriteLine(e.ProgressPercentage);
      }
  
      void bw_DoWork(object sender, DoWorkEventArgs e)
      {
          for (int i=0; i &lt; 10000; i++)
          {
              bw.ReportProgress((i*100)/10000);
          }
      }
  
  }
  </code></pre>