title: The current SynchronizationContext may not be used as a TaskScheduler
body: <p>I am using <a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx" rel="noreferrer">Tasks</a> to run long running server calls in my ViewModel and the results are marshalled back on <code>Dispatcher</code> using <code>TaskScheduler.FromSyncronizationContext()</code>. For example:</p>
  
  <pre><code>var context = TaskScheduler.FromCurrentSynchronizationContext();
  this.Message = "Loading...";
  Task task = Task.Factory.StartNew(() =&gt; { ... })
              .ContinueWith(x =&gt; this.Message = "Completed"
                            , context);
  </code></pre>
  
  <p>This works fine when I execute the application. But when I run my <code>NUnit</code> tests on <code>Resharper</code> I get the error message on the call to <code>FromCurrentSynchronizationContext</code> as: </p>
  
  <blockquote>
    <p>The current SynchronizationContext may not be used as a TaskScheduler.</p>
  </blockquote>
  
  <p>I guess this is because the tests are run on worker threads. How can I ensure the tests are run on main thread ? Any other suggestions are welcome.</p>