Tasks and the AggregateException
When running a task asynchronous in an asynchronous environment, you can catch exceptions as you just using asynchronous code. When an exception occurs, C# will catch any exception and put it into the Task that will be returned to the caller. Furthermore, the Task becomes Faulted. The exception will be thrown now at the place where the await is put to wait for the result of the asynchronous call which caused the exception.
This changes however when calling a asynchronous task in a synchronous way.
Read More…Posted in C# at August 13th, 2019. No Comments.