liveBook · Manning

Awaiter

As explained in C# Concurrency: Asynchronous and multithreaded programming

An awaiter is an object that provides the compiler-facing mechanism for determining completion and retrieving the result of an awaitable operation.

An awaiter is the compiler-facing object that coordinates an awaitable operation: it determines completion and retrieves the result. The compiler-generated async method uses an awaiter rather than ContinueWith, within a state machine that tracks execution position. section 3.3

ContinueWith models only the callback-after-completion part. Await additionally supports the surrounding asynchronous control flow, allowing code such as sequential file reads to remain readable while returning control to the caller. section 3.3

Reading a bitmap width

GetBitmapWidth awaits two FileStream reads, validates the BMP header and read lengths, seeks to the width field, converts four bytes, and returns the result. The compiler divides this flow into resumable state-machine chunks. section 3.3

How C# Concurrency: Asynchronous and multithreaded programming covers it

How deep it goes
Descends to state-machine generation and awaiter substitution, but defers awaiter's additional features to later treatment.
Examples
Uses asynchronous BMP header and width reads, alongside nested ContinueWith callbacks, to contrast compiler-friendly and manual continuation styles.
What you can do after
Evaluate/understand how the compiler transforms await-based file operations into resumable state-machine execution.
How it connects
Connects awaiters with async methods, await, Task, ContinueWith, and compiler-generated state machines.

This explainer was generated by Manning's knowledge graph from the text of C# Concurrency: Asynchronous and multithreaded programming. The section links point to the parts of the book it draws on.