I am looking to use Task.WhenAll in a situation where some tasks may fail, but I still need the result data from the rest of the completed tasks.
According to MSDN,
If any of the supplied tasks completes in a faulted state, the returned task will also complete in a Faulted state, where its exceptions will contain the aggregation of the set of unwrapped exceptions from each of the supplied tasks.
However, what it doesn't say, is whether or not Task.WhenAll will still wait for the rest of the Tasks to complete in that instance. Can anyone provide any clarification on this issue?
As the documentation says:
Creates a task that will complete when all of the Task objects in an enumerable collection have completed.
So it will wait for all tasks to complete, regardless of whether any have thrown an exception already or been cancelled. Then it will aggregate the possible cancellations and exceptions and define its state. The results of the given tasks will be in the original tasks, as well as the exceptions and cancellations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With