Async Wandering Part 6 — Exceptions logging

This is the sixth part of the Async Wandering series. For your convenience you can find other parts in the table of contents in Part 1 – Why creating Form from WinForms in unit tests breaks async?

Let’s take the following code:

We create a task and add two child tasks to it, both of them throwing exceptions. What is the output?

So we lost one exception. This is a case when introducing async changes semantics and doesn’t integrate with the platform nicely. How to fix that?

With this:

This correctly prints out both exceptions, however, we need to use normal TPL methods.