Your Ultimate async / await Tutorial in C#
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
There are some libraries in .Net Framework 4.5, that has a built-in support for asynchronous programming using async
/ await
keywords.
These libraries, such as the HttpClient, StreamWriter, StreamReader and many more, provide you async methods that you can use in your program directly with await.
They have been added with the async/await capabilities because these provide functionalities that require long-running operations such as reading large file or download huge resources.
So the async
/ await
will significantly improve the performance of your application while not blocking the UI or the execution.
I/O Bound async / await
Let's take an example for using the HttpClient's GetStringAsync
method, that will hit a provided URL and return the html response content from it and display its length on Console screen: