title: C# progressbar IsIndeterminate while exectue a function
body: <p>I'd like to have a indeterminate progress bar going while I'm doing a function. The problem is that while the function is working the UI freeze until the end so I end up with:</p>
  
  <pre><code>void Button1_Click(object sender, RoutedEventArgs e)
  {
      progressBar1.IsIndeterminate = true;
      Task.Factory.StartNew(() =&gt;
      {
              scrape();
      });
  }
  </code></pre>
  
  <p>The thing is that as for backgroundworker, my scrape function don't trigger. I put just the scrape(); onclick it work just fine. The scarpe is something like:</p>
  
  <pre><code>void scrape()
  {
      string url = "www.site.com";
      var web = new HtmlWeb();
      var doc = web.Load(url);
  
      foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//p[@class='bio']")) 
      {   
          //scrape things
      }
  
      progressBar1.IsIndeterminate = false;
  }
  </code></pre>
  
  <p>The progress bar go in indeterminate but the scrape() don't trigger and the bar still in indeterminate state.
  Any help?</p>