title: Why was "SwitchTo" removed from Async CTP / Release?
body: <p>I tried to use the SwitchTo method today to switch to the GUI thread, and found that the example I lifted it from does not work, simply because the method is not there.</p>
  
  <p>I then found this blurb <a href="http://social.msdn.microsoft.com/Forums/en-US/async/thread/078c7e77-5b16-4130-bbf5-c8e6ac82effa">here</a>:</p>
  
  <blockquote>
    <p>The reason we got rid of it was because it was so dangerous. The alternative is to bundle up your code inside TaskEx.Run...</p>
  </blockquote>
  
  <p>My question is simply: <em>Why</em> was it dangerous? What specific dangers would using it lead to?</p>
  
  <p>Note that I <em>did</em> read the rest of that post, so I do understand there are technical limitations here. My question is still, if I'm aware of this, why is it <em>dangerous</em>?</p>
  
  <p>I am considering reimplementing helper methods to give me the specified functionality, but if there is something fundamentally broken, other than that someone decided it was dangerous, I would not do it.</p>
  
  <p>Specifically, very naively, here's how I would consider implementing the required methods:</p>
  
  <pre><code>public static class ContextSwitcher
  {
      public static ThreadPoolContextSwitcher SwitchToThreadPool()
      {
          return new ThreadPoolContextSwitcher();
      }
  
      public static SynchronizationContextSwitcher SwitchTo(this SynchronizationContext synchronizationContext)
      {
          return new SynchronizationContextSwitcher(synchronizationContext);
      }
  }
  
  public class SynchronizationContextSwitcher : INotifyCompletion
  {
      private readonly SynchronizationContext _SynchronizationContext;
  
      public SynchronizationContextSwitcher(SynchronizationContext synchronizationContext)
      {
          _SynchronizationContext = synchronizationContext;
      }
  
      public SynchronizationContextSwitcher GetAwaiter()
      {
          return this;
      }
  
      public bool IsCompleted
      {
          get
          {
              return false;
          }
      }
  
      public void OnCompleted(Action action)
      {
          _SynchronizationContext.Post(_ =&gt; action(), null);
      }
  
      public void GetResult()
      {
      }
  }
  
  public class ThreadPoolContextSwitcher : INotifyCompletion
  {
      public ThreadPoolContextSwitcher GetAwaiter()
      {
          return this;
      }
  
      public bool IsCompleted
      {
          get
          {
              return false;
          }
      }
  
      public void OnCompleted(Action action)
      {
          ThreadPool.QueueUserWorkItem(_ =&gt; action(), null);
      }
  
      public void GetResult()
      {
      }
  }
  </code></pre>
  
  <p>This would allow me to write code like this:</p>
  
  <pre><code>public async void Test()
  {
      await ContextSwitcher.SwitchToThreadPool(); // ensure we're not bogging down the UI thread
      // do some heavy processing
      await _UIContext.SwitchTo(); // presumably saved from the main thread
      // update UI with new data
  }
  </code></pre>