Friday, March 13, 2015

Async/Await Explained

Last night I had the opportunity to present at the Gwinnett Microsoft .NET User Group. The topic I chose is not a new one, but an important one. Recently in several interviews I've been surprised to learn how little is truly understood about multi-threading in managed code and specifically the use of the async and await keywords. This presentation was designed specifically to walk through the basics behind threading and demonstrate when and how it is useful. The abstract and deck are below, along with a link to the repository with sample code.

Although two new keywords have been lurking in C# for years now, many people still don't fully understand what they do or how they facilitate asynchronous programming. Contrary to what some developers seem to believe, tagging a method as async doesn't make it run in a separate thread and await doesn't pull threads from the thread pool. These contextual keywords cause the compiler to generate complicated code so you don't have to with numerous advantages from improving the responsiveness of your application, simplifying the source, and enabling better scale. Learn exactly how async and await work, what happens under the covers, when you should use them and how to write your own APIs to take advantage of async and await whether it's in Windows Runtime, desktop, or web-based applications. (Full Source and Deck)

Jeremy Likness