title: TaskEx.Yield(TaskScheduler)
body: <p>Last month I asked the following question which resulted in my learning of <code>TaskEx.Yield</code>:</p>
  
  <p><a href="https://stackoverflow.com/questions/8449111/can-async-methods-have-expensive-code-before-the-first-await">Can async methods have expensive code before the first &#39;await&#39;?</a></p>
  
  <p>However, I have since realized that this method actually submits all subsequent code to the ambient <code>TaskScheduler</code>. In true DI spirit, our team has agreed to avoid using ambient instances where possible, so I would like to know if it's possible to explicitly specify a <code>TaskScheduler</code> to use?</p>
  
  <p>Something like the following would be great:</p>
  
  <pre><code>public static YieldAwaitable Yield(TaskScheduler taskScheduler)
  {
      return new YieldAwaitable(taskScheduler);
  }
  </code></pre>
  
  <p>However, the current implementation of Async CTP only offers:</p>
  
  <pre><code>public static YieldAwaitable Yield()
  {
      return new YieldAwaitable(SynchronizationContext.Current ?? TaskScheduler.Current);
  }
  </code></pre>
  
  <p>Would the following provide an acceptably efficient alternative?</p>
  
  <pre><code>await Task.Factory.StartNew(() =&gt; { }, CancellationToken.None, TaskCreationOptions.None, this.TaskScheduler);
  </code></pre>