I have a question on TPL tasks. I have some tasks that are a "Show Stoppers", once one of them is faulted i dont want the method to continue running but give an exception and exit. I tried using TaskContinuationOptions, something like this:
var res = Task.Factory.ContinueWhenAny(
new[] { task1, task2, task3},
task =>
{
throw task.Exception.Flatten();
},
CancellationToken.None,
TaskContinuationOptions.OnlyOnFaulted,
this.taskScheduler);
var res1 = Task.Factory.ContinueWhenAll(
new[] { task1, task2, task3},
tasks =>
{
// DO SOME CODE
},
CancellationToken.None,
TaskContinuationOptions.NotOnFaulted,
this.taskScheduler);
return Task.WhenAny(res, res1).Unwrap();
But unfortunately there is a limitation filtering on a TaskContinuationOptions when continuing on more that a one task. What is the solution to this?