title: Run Tasks on a separate thread with return value
body: <p>I'm developping an application that should run a new task , makes some stuff and return a list of objects... </p>
  
  <p>when spawning the new task , i need to simulate in my UI thread a progressbar changing in a for loop... and after the task completion , i have to update my view ( by updating the values of my ViewModel properties as i'm using MVVM pattern).</p>
  
  <p>the problem is that when the task is launched, the GUI freezes and the progress bar is not updated! i thought that tasks are run in background on a sperate thread ( as they are pooled). so why my GUI is blocked?? </p>
  
  <p>here is a snippet of my code :</p>
  
  <pre><code>Task&lt;List&lt;Items&gt;&gt; myTask = Task.Factory.StartNew(() =&gt; queryHandler.GetItemssStatistics(items, sec, buyer, seller, From, To));
  
  //Here is the simulation of ProgressBar changing that i need to be done when task is started
                      for (int i = 0; i &lt; 100; i++)
                      {
  Thread.Sleep(100);
                          StatusValue = i+1;
                      }
  //Here is the section i need to do once the task finishes its execution to update my VM
  //Wait for the task to finish its execution and retreive results:
                      List&lt;Items&gt; _tempResults = myTask.Result;
                      foreach (Items d in _tempResults)
                      {
                          ResultsList.Add(d);
                      }
  
                      if (ResultsList.Count == 0)
                      {
                          MessageBox.Show("Sorry, No items matched the defined research criteria!", "Warning",
                                          MessageBoxButton.OK,
                                          MessageBoxImage.Warning, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
                      }
                      else
                      {
                          //Show items:
                          ResultsAvailable = Visibility.Visible;
  
                      }
  </code></pre>