Exception Behavior

During the discussion about the APM and the EAP, you saw how dealing with errors can be tricky. The problem with those patterns lies in their multiphased nature, where exceptions can occur at various stages. In the world of the APM, exceptions can come out during Begin and End method calls. When using the EAP, exceptions can occur during the Async start operation, but can be reported through the Completed event arguments as well.

For the TAP, things are much simpler. Other than method parameter usage exceptions (such as ArgumentException), no errors should be raised when invoking the TAP method. Instead, all exceptions have to be propagated through the returned task object. Users of the method can inspect the returned task ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.