TPL has several TaskContinuationOptions values that determine the circumstances in which the task runs. For example, TaskContinuationOptions.NotOnCanceled prevents the task from starting when the parent element is disabled.
However, none of these task state filters apply to the continuation of several tasks. You cannot do something like:
TaskFactory f = new TaskFactory(); Task t1 = new Task (() => Thread.Sleep (5000)); Task t2 = new Task (() => Thread.Sleep (4000)); Task t3 = f.ContinueWhenAll (new Task[] { t1, t2 }, (tasks) => { ... }, TaskContinuationOptions.OnlyOnRanToCompletion);
As a result, you get the error message "It is invalid to exclude specific continuation kinds for continuations off of multiple tasks."
I do not understand why this condition will be excluded from the API. Why not be a perfectly acceptable use case, so that the task is performed only when all the antecedents have ended in a certain state?
Colin
source share