Thanks to captured context it will be done on UI thread.If it were not for capturing context we would end up updating textbox object from non-UI thread, that would lead to an exception.
It means that code before and after “await” statement will be executed on a thread owning captured context. Without synchronization context, async method code will be executed using thread pool context on any currently available thread.Here is an example of some WPF element event handler: Here we start running method on a UI thread.Instead exception will be raised on the Synchronization Context that was active when async void method started. Async/await is syntactic sugar, not available at IL/CLR level.That is why compiler will generate state machine based on the method above, full of much boilerplate code.However, there are many cases when we do not need to switch contexts and execute code on some specific thread.
Not only because it may be unnecessary, but it also may cause performance loss.In this case we can setup how we want to await asynchronous operation using Configure Await method.Code above uses Configure Await(false) to prevent context capturing, therefore after awaiting remaining code will be executed on any available thread from the thread pool.5.Dealing with the unwrapped exceptions is easier and better in terms of code readability.Sometimes aggregate exception contains more than one exception.Even though async/await mechanism lets you do complicated things easier, it is still the complicated subject by itself.