Piguy Piguy - 5 months ago 49
C# Question

How to handle exceptions in Parallel.Foreach?

I have a parallel.Foreach loop in my code and I am wondering how to handle exceptions. Should I catch and handle(e.g write to log) exceptions inside the loop or should I catch aggregate exception outside - encapuslate the loop in try/catch?

Best regards


This MSDN Article should answer your question. It's pretty simple.