title: Difference between the TPL & async/await (Thread handling)
body: <p>Trying to understanding the difference between the TPL &amp; <code>async</code>/<code>await</code> when it comes to thread creation.   </p>
  
  <p>I believe the TPL (<code>TaskFactory.StartNew</code>) works similar to <code>ThreadPool.QueueUserWorkItem</code> in that it queues up work on a thread in the thread pool. That's of course unless you use <code>TaskCreationOptions.LongRunning</code> which creates a new thread.   </p>
  
  <p>I thought <code>async</code>/<code>await</code> would work similarly so essentially:</p>
  
  <p>TPL:</p>
  
  <pre><code>Factory.StartNew( () =&gt; DoSomeAsyncWork() )
  .ContinueWith( 
      (antecedent) =&gt; {
          DoSomeWorkAfter(); 
      },TaskScheduler.FromCurrentSynchronizationContext());
  </code></pre>
  
  <p><code>Async</code>/<code>Await</code>:</p>
  
  <pre><code>await DoSomeAsyncWork();  
  DoSomeWorkAfter();
  </code></pre>
  
  <p>would be identical. From what I've been reading it seems like <code>async</code>/<code>await</code> only "sometimes" creates a new thread. So when does it create a new thread and when doesn't it create a new thread? If you were dealing with IO completion ports i can see it not having to create a new thread but otherwise I would think it would have to. I guess my understanding of <code>FromCurrentSynchronizationContext</code> always was a bit fuzzy also. I always throught it was, in essence, the UI thread.</p>