Exception handling is one of the most important aspects of parallel programming. All good clean code practitioners focus on handling exceptions efficiently. This becomes even more important with parallel programming as any unhandled exceptions in threads or tasks can cause the application to crash abruptly. Fortunately, TPL provides a nice, efficient design to handle and manage exceptions. Any unhandled exceptions that occur in a task are deferred and then propagated to a joining thread, which observes the task for exceptions.
Any exception that occurs inside a task is always wrapped under the AggregateException class and returned to the caller that is observing the exceptions. If the caller is waiting on a single task, the inner exception property of the AggregateException class will return the original exception. If the caller is waiting for multiple...