Building Awaitable Types
Starting from C# 3.0, new language features have not required any change to the underlying CLR infrastructure. This is no different for the asynchronous programming features introduced in C# 5.0. As discussed in depth in the previous section, asynchronous methods use a crafty compile-time rewrite technique to produce a regular method from the runtime’s point of view. Control flow constructs are rewritten in terms of interactions with a method builder object provided in the BCL for .NET Framework 4.5.
Although you could totally imagine a runtime extension to make methods pausable—effectively hoisting the stack frame onto the heap, or using a different technique altogether—there’s no need to make such big changes to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access