O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unwrapping AggregateExceptions

What about tasks that have multiple exceptions? As you might recall from Chapter 30, you can use Task objects for parallel computing where multiple units of work can fail. A good example of this behavior is the use of the Parallel class to run multiple loop iterations in parallel. To capture all possible exception states, the AggregateException type was introduced in .NET 4.0. Handling such an exception can be quite tedious, though, because regular catch blocks cannot be used to inspect any of the object’s inner exceptions. Instead, a Handle method has to be called, specifying a handler method through a delegate.

Nowadays, tasks are increasingly commonly used as futures that represent the eventual completion of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required