title: C# WPF Indeterminate progress bar
body: <p>Please could someone suggest why the following doesn't work? All I want to do is display an indeterminate progress bar which starts when the button is clicked, then after I've done some work I set the indeterminate progress bar to false to stop it.</p>
  
  <p>However when I run the code below the indeterminate progress bar doesn't even start. I tried commenting out the line <code>this.progressBar.IsIndeterminate = false</code> and when I do this the progress bar does start but then doesn't terminate.</p>
  
  <pre><code>private void GenerateCSV_Click(object sender, RoutedEventArgs e)
  {
      this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate ()
      {
          this.progressBar.IsIndeterminate = true;
  
          // do some work
          Thread.Sleep(10 * 1000);
  
          this.progressBar.IsIndeterminate = false;
      }));
  }
  </code></pre>