Exception Handling

Handling exceptions is a crucial topic in parallel programming. The problem is that multiple tasks that run concurrently could raise more than one exception concurrently, and you need to understand what the actual problem is. The .NET Framework 4.0 offers the System.AggregateException class that wraps all exceptions occurred concurrently into one instance. The class then exposes, over classic properties, an InnerExceptions collection that you can iterate for checking what exceptions occurred. The following code demonstrates how you catch an AggregateException and how you iterate the instance:

image

Each item in InnerExceptions is ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.