In the previous guide in this series we took a look at the basics of the async and await keywords in C#. Once you get the hang of their syntax and usage, it can actually be quite a joy to write asynchronous code. In fact,
In the previous guide in this series we took a look at the basics of the async and await keywords in C#. Once you get the hang of their syntax and usage, it can actually be quite a joy to write asynchronous code. In fact, it feels so natural that one can forget that the code is asynchronous! Often this is an advantage; you can ignore the minutiae and focus on the application you're building. But, sooner or later, you will come across some confusing behavior that will remind you how tricky asynchronicity can be. It's at these moments that understanding what happens under the hood when using async and await becomes important. It turns out that there is a lot going on.
In this tutorial we take a look at how to use async, await and Task in C#. Primarily looking at good practices and how to avoid common pitfalls such as creating unecessary state machines, blocking threads, using ConfigureAwait when making libraries and how to avoid async in constructors.
Asynchronous programming can be intimidating. What's even worse is when you think you learned how to do something and then you try it in your application and it doesn't work. This video is an attempt to fix all of that.