Task with OnFaulted continuation throws TaskCancelledException on WaitAll
Ran into this today. Can anyone explain why this throws a
TaskCancelledException ?
Task[] tasks = new Task[4];
for (int i = 0; i < 4; i++)
{
Task t = Task.Run(() => { }).ContinueWith((task) => { },
TaskContinuationOptions.OnlyOnFaulted);
tasks[i] = t;
}
Task.WaitAll(tasks);
If I specify NotOnFaulted instead - it works.
No comments:
Post a Comment