title: Does .NET resume an await continuation on a new different thread pool thread or reuse the thread from a previous resumption?
body: <p>Does .NET resume an await continuation on a new different thread pool thread or reuse the thread from a previous resumption?</p>
  
  <p>Let's image below C# code in a .NET Core console application:</p>
  
  <pre><code>using System;
  using System.Threading;
  using System.Threading.Tasks;
  
  namespace NetCoreResume
  {
      class Program
      {
          static async Task AsyncThree()
          {
              await Task.Run(() =&gt;
              {
                  Console.WriteLine($"AsyncThree Task.Run thread id:{Thread.CurrentThread.ManagedThreadId.ToString()}");
              });
  
              Console.WriteLine($"AsyncThree continuation thread id:{Thread.CurrentThread.ManagedThreadId.ToString()}");
          }
  
          static async Task AsyncTwo()
          {
              await AsyncThree();
  
              Console.WriteLine($"AsyncTwo continuation thread id:{Thread.CurrentThread.ManagedThreadId.ToString()}");
          }
  
          static async Task AsyncOne()
          {
              await AsyncTwo();
  
              Console.WriteLine($"AsyncOne continuation thread id:{Thread.CurrentThread.ManagedThreadId.ToString()}");
          }
  
          static void Main(string[] args)
          {
              AsyncOne().Wait();
  
              Console.WriteLine("Press any key to end...");
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>It will output:</p>
  
  <pre><code>AsyncThree Task.Run thread id:4
  AsyncThree continuation thread id:4
  AsyncTwo continuation thread id:4
  AsyncOne continuation thread id:4
  Press any key to end...
  </code></pre>
  
  <p>I have tried to add <code>ConfigureAwait(false)</code> after each await <code>Task</code>, but it will get the same result.</p>
  
  <p>As we can see, it seems like all await continuations reused the thread created in <code>Task.Run</code> of <code>AsyncThree()</code> method.
  I want to ask if .NET will always resume the await continuation on previous resumption thread, or it will apply a new different thread from thread pool in some occasions?</p>
  
  <p>I knew there is answer the continuation will resume on <strong>a thread pool thread</strong> in below discussion:</p>
  
  <p><a href="https://stackoverflow.com/questions/31186354/async-await-where-is-continuation-of-awaitable-part-of-method-performed">async/await. Where is continuation of awaitable part of method performed?</a></p>
  
  <p>Let's exclude the <code>SynchronizationContext</code> case in above link, since we are now discussing a .NET console application. But I want to ask it seems like <strong>that thread pool thread</strong> in my example is always <code>thread id 4</code>, I don't know whether it is because <code>thread id 4</code> is always free in the thread pool, so every continuation reuse it by coincidence, or .NET has mechanism will reuse the previous resumption thread as much as possible?</p>
  
  <p>Is there any possibility each continuation will resume on a different thread pool thread like below?</p>
  
  <pre><code>AsyncThree Task.Run thread id:4
  AsyncThree continuation thread id:5
  AsyncTwo continuation thread id:6
  AsyncOne continuation thread id:7
  Press any key to end...
  </code></pre>