Piguy Piguy - 1 year ago 127
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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download