I have tried to find out how exceptions and cancel work for Parallel.Foreach
. All examples seems to deal with Tasks.
What happens on an exception in Parallel.Foreach
?
- Do I wrap the entire loop in try/catch (
AggregateException
)? - Will all other tasks in the loop, even tasks not started yet, run to completion before the exception is caught?
Same questions for CancellationToken
.