title: Waiting for multiple tasks when some might be cancelled
body: <p>I'm trying to wait for multiple tasks, and I expect that some might be cancelled. I'm using <a href="https://stackoverflow.com/questions/40595720/task-waitall-throws-operationcanceledexception">this</a> question as a source of inspiration to have <code>WhenAll</code> handle cancelled tasks accordingly...</p>
  <p>However, if none of the tasks ever get cancelled, this in turn throws an exception too!</p>
  <pre><code>var source = new CancellationTokenSource();
  
  var task1 = Task.Delay(100, source.Token);
  source.Cancel();
  var task2 = Task.Delay(300);
  
  await Task.WhenAll(task1, task2).ContinueWith(_ =&gt; { }, TaskContinuationOptions.OnlyOnCanceled);
  </code></pre>
  <p>In the example above if the <code>source.Cancel()</code> is NOT executed, then the final <code>await</code> will throw an exception. I could fix that by removing the <code>ContinueWith</code> from the final line, but then if a task IS cancelled, the <code>WhenAll</code> will fail with the same error.</p>
  <p>What's the correct course of action to wait for a list of tasks when some of them might (but don't have to) be cancelled?</p>