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
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.