Skip to content
Justice Tech School

async and await

async methods return Task. await waits without blocking the thread.

Example
static async Task<int> GetAsync() { await Task.Delay(10); return 42; }
int r = await GetAsync();
Console.WriteLine(r);
var results = await Task.WhenAll(GetAsync(), GetAsync());
Console.WriteLine(results.Sum());

Exercise

Wait for a task.

 GetAsync()

Quiz Test

What does async Task<int> return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.