async and await arrived in C# 5.0. They simplify asynchronous programming by letting you pause and resume work without manually wiring continuations.
Why it matters
This feature is critical for web apps, APIs, and desktop apps that need to stay responsive during network, disk, or database waits.
Instead of blocking a thread, asynchronous methods return control to the caller and resume when the awaited operation finishes.
Cautions
Use await all the way through the call chain when possible. Mixing async and blocking calls (.Result, .Wait()) can cause deadlocks or thread starvation.
Also make the method name tell the truth. In .NET code, asynchronous methods usually end with Async.
Awaiting an I/O-bound operation
Async methods let you keep the thread free while waiting on I/O-heavy work like HTTP calls or file access.
Valid since C# 5.0
public class ProfileService
{
public async Task<string> LoadProfileAsync(HttpClient client, string id)
{
var response = await client.GetAsync($"/profiles/{id}");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}