title: Update GUI from Task
body: <p>I'm trying to create a method that will encapsulate all GUI operations from a different thread, however when I use it nothing happens and no exception is thrown.<br>
  This is what I got:</p>
  
  <pre><code>    private Task t1;
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          t1 = Task.Factory.StartNew(() =&gt; DoStuffInTask())
              .ContinueWith(tsk =&gt; Finished(tsk));
      }
  
      private void DoStuffInTask()
      {
          //doing important stuff...
          for (int i = 0; i &lt; Int16.MaxValue; i++)
          {
              //Text is a property that raises INotifyPropertyChanged event
              RunOnGui(() =&gt; { Text = i.ToString(); }); // not working, not throwing exception
              Application.Current.Dispatcher.Invoke(() =&gt; Text = i.ToString()); // works fine
          }
      }
  
      private void RunOnGui(Action action)
      {
          Application.Current.Dispatcher.Invoke(() =&gt; action);
      }
  </code></pre>