Introduction
Until now, we learned about Task Parallel Library, the latest asynchronous programming infrastructure from Microsoft. It allows us to design our program in a modular manner, combining different asynchronous operations together.
Unfortunately, it is still difficult to understand the actual program flow when reading such a program. In a large program, there will be numerous tasks and continuations that depend on each other, continuations that run other continuations, continuations for exception handling, and they are all gathered together in the program code in very different places. Therefore, to understand the sequence of which operation goes first and what happens next becomes a very challenging problem.
Another issue to watch out for is to see if the proper synchronization context is propagated to each asynchronous task that could touch user interface controls. It is only permitted to use these controls from the UI thread; else, we would get a multithreaded access exception...