Introducing async and await

async and await are two very popular keywords among .NET Core developers writing asynchronous code with the new asynchronous APIs provided by .NET Framework. They are used for marking code when calling asynchronous operations. In the last chapter, we discussed the challenges of converting a synchronous method into an asynchronous one. Previously, we did this by breaking down the method into two methods, BeginMethodName and EndMethodName, which can be called asynchronously. This approach makes the code clumsy and difficult to write, debug, and maintain. With the async and await keywords, however, the code can stay how it was in the synchronous implementation, with only small changes required. All the difficult work ...

Get Hands-On Parallel Programming with C# 8 and .NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.