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 ...
Get C# 5.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.