C# is a great programming language and it continues to evolve at a good pace even 15 years after it’s introduction.
One of the best features to ever be added to C# / .NET was async / await.
Early writers of asynchronous code used IAsyncResult and after that came the Task Parallel Library. But the TPL was still relatively difficult to use so most programmers only wrote asynchronous code when they really had to.
And then along came async / await which made our lives so much easier. Everyone and their dog can write asynchronous code. Hidden in that simplicity, however, is a lot of complexity and a few assumptions.
Today, we’re going to be talking about one of the biggest gotchas… It’s a suprising detail that a lot of experienced .NET developers don’t know about. It’s about await and the synchronization context.