title: Passing cancellation token to Task.Run seems to have no effect
body: <p>According to <a href="https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-cancel-a-task-and-its-children" rel="nofollow noreferrer">this</a> and <a href="https://stackoverflow.com/a/3713113/1836773">this</a>, passing a cancellation token to a task constructor, or <code>Task.Run</code>, will cause the task to be associated with said token, causing the task to transition to <code>Canceled</code> instead of <code>Faulted</code> if a cancellation exception occurs.</p>
  <p>I've been fiddling with these examples for a while, and I can't see any benefits other than preventing a cancelled task to start.</p>
  <p>Changing the code on <a href="https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-cancel-a-task-and-its-children" rel="nofollow noreferrer">this MSDN example</a> from</p>
  <pre><code>tc = Task.Run(() =&gt; DoSomeWork(i, token), token);
  </code></pre>
  <p>to</p>
  <pre><code>tc = Task.Run(() =&gt; DoSomeWork(i, token));
  </code></pre>
  <p>produced the exact same output:</p>
  <p><a href="https://i.stack.imgur.com/rMyb3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rMyb3.png" alt="enter image description here" /></a></p>
  <p>This code also results in two cancelled state tasks with the same exceptions thrown:</p>
  <pre><code>var token = cts.Token;
  
  var t1 = Task.Run(() =&gt;
  {
      while (true)
      {
          Thread.Sleep(1000);
          token.ThrowIfCancellationRequested();
      };
  });
  
  var t2 = Task.Run(() =&gt;
  {
      while (true)
      {
          Thread.Sleep(1000);
          token.ThrowIfCancellationRequested();
      };
  }, token);
  
  Console.ReadKey();
  
  try
  {
      cts.Cancel();
      Task.WaitAll(t1, t2);
  }
  catch(Exception e)
  {
      if (e is AggregateException)
      {
          foreach (var ex in (e as AggregateException).InnerExceptions)
          {
              Console.WriteLine(e.Message);
          }
      }
      else
          Console.WriteLine(e.Message);
              
  }
  
  Console.WriteLine($&quot;without token: { t1.Status }&quot;);
  Console.WriteLine($&quot;with token: { t2.Status }&quot;);
  Console.WriteLine(&quot;Done.&quot;);
  </code></pre>
  <p><a href="https://i.stack.imgur.com/lBxPn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lBxPn.png" alt="enter image description here" /></a></p>
  <p>Apparently, throwing <code>OperationCanceledException</code> from within the task is enough to make it transition to <code>Canceled</code> instead of <code>Faulted</code>. So my question is: is there a reason for passing the token to the task other than preventing a cancelled task to run?</p>