Back
Close

Your Ultimate async / await Tutorial in C#

AramT
331.2K views

There are some libraries in .Net Framework 4.5, that has a built-in support for asynchronous programming using asyncawait 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 asyncawait 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:

Click run to see the console output
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io