Asynchronous Methods and await Expressions

As part of the .NET 4.5 release, new language features for asynchronous programming were added to both C# 5.0 and Visual Basic 11. Their main goal is to take away the burden of having to restructure asynchronous code using a callback pattern, as seen with the APM, EAP, and TAP. By doing so, developers can focus on the logical flow of control of their application, rather than having to worry about the mechanics of how the code ultimately executes.

In other words, the language allows users to express what they want, instead of having to express—in excruciating details—how things should be carried out at runtime. Compilers are incredibly good at making such transformations, as seen in many language features ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.