CKTIS / C#
await: practical reference
await: practical reference: await asynchronously waits for an awaitable and resumes the method after completion.
Version: C# language; verified against C# 14 reference
Syntax
await operandawait asynchronously waits for an awaitable and resumes the method after completion.
Use it instead of blocking Wait or Result, propagating Task and CancellationToken.
It does not create a thread; it may capture a context, and rethrows the exception at await.
An already-completed awaitable may continue synchronously; usually await a ValueTask only once.
The complete program actually uses await; its exact expected stdout is 8.
Examples
using System;
using System.Linq;
using System.Threading.Tasks;
var value = await Task.FromResult(8); Console.WriteLine(value);
Result
8
The complete program actually uses `await`; its exact expected stdout is `8`.