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 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.