Awaited task ended in Canceled state does not throw
<p>Reading <a href="https://www.microsoft.com/en-us/download/details.aspx?id=19957" rel="nofollow noreferrer">Task-based Asynchronous Pattern</a> by Stephen Toub I'm trying to see how cancellation works for tasks.
In the section <em>Consuming the Task-based Asynchronous Pattern</em> under <strong>Await</strong>, in 3-rd paragraph it says:</p>

<blockquote>
  <p>If the Task or Task TResult> awaited ended in the Canceled state, an
  OperationCanceledException will be thrown.</p>
</blockquote>

<p>I'm trying to see this in action in the code below.</p>

<pre><code>static void Main(string[] args)
{
   CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
   CancellationToken cancellationToken = cancellationTokenSource.Token;

   Task&lt;int&gt; valueTask = DoStuffAsync(cancellationToken);
   Thread.Sleep(TimeSpan.FromSeconds(1));
   cancellationTokenSource.Cancel();

   Console.WriteLine("value task's status: {0}", valueTask.Status); 
   Console.ReadLine();
}
</code></pre>

<p>And the <code>DoStuffAsync()</code> method</p>

<pre><code>static async Task&lt;int&gt; DoStuffAsync(CancellationToken cancellationToken)
{
    await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
    return 42;
}
</code></pre>

<p>Executing this code doesn't throw any exception, it just prints:</p>

<blockquote>
  <p>value task's status: Cancelled</p>
</blockquote>

<p>Now, my expectation was in <code>DoStuffAsync()</code> method since <code>await Task.Delay(...)</code> is cancelled, we have awaited task ended in Canceled state, hence exception should have been thrown (according to quote from the TAP document), but if I put a breakpoint on <code>Console.ReadLine()</code> and check <code>valueTask</code> it's Status is Cancelled, and Exception is <code>null</code>.</p>

<p>Can anybody help me understand if I misread the document, or code I come up with is not properly reproducing the case?</p>