O'Reilly logo

C# Multithreaded and Parallel Programming by Rodney Ringler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The async and await keywords

In .NET 4.5, Microsoft introduced the async and await keywords that made it very easy for developers to implement asynchronous functionality in their methods. Adding the async keyword to the method header tells .NET's CLR to run this method in a separate thread in the threadpool if it determines that the following two conditions are met: first, that running it in a separate thread will increase performance, and second, the await keyword is used in the method. An async method will either return void, Task, or Task<TResult>. Also, the naming convention is to postfix any methods that use the async keyword with Async. So, the method name should be MyMethodAsync. That is all there is to it. The implementation is similar ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required