title: Avoid capturing current execution context when using Task.Run
body: <p>I would like to create/run a task without capturing the current execution context. Is this possible?</p>
  <p>Consider the following sample:</p>
  <pre><code>private static readonly AsyncLocal&lt;object&gt; AsyncLocal = new AsyncLocal&lt;object&gt;();
  
  [TestMethod]
  public void TaskRunCapturesContext()
  {
      AsyncLocal.Value = 1;
      var task = Task.Run(static async () =&gt;
          {
              await Task.Delay(1).ConfigureAwait(false);
              Console.WriteLine(AsyncLocal.Value); // Prints &quot;1&quot;, expected is &quot;&quot; &lt;-- Problem HERE
              AsyncLocal.Value = 2;
              Console.WriteLine(AsyncLocal.Value); // Prints &quot;2&quot;, expected is &quot;2&quot;
          });
  
      Task.WaitAll(task);
      Console.WriteLine(AsyncLocal.Value); // Prints &quot;1&quot;, expected is &quot;1&quot;
  }
  </code></pre>
  <p>Is it possible to make the first <code>Console.WriteLine(AsyncLocal.Value);</code> print <code>&quot;&quot;</code> instead of <code>&quot;1&quot;</code> (because AsyncLocal.Value is null/not initialized)?</p>
  <p>I also played around with all overloads of the more explicit Task.Factory-method, but I couldn't find a solution. Form the source it can also be seen that Task.Run(Action) translates into a call to <code>Task.InternalStartNew(null, action, null, ..)</code> which explicitly passes <code>null</code> as <code>state</code>-argument, so I dont see a way I could be more explicit.</p>
  <p>Thanks in advance</p>