Is the new C# async feature implemented strictly in the compiler

后端 未结 1 862
孤城傲影
孤城傲影 2021-01-18 11:47

As a C# programmer whose interested in exploring \"how things work\", i am interested in understanding a bit more about the process that makes the new async feature

相关标签:
1条回答
  • 2021-01-18 12:10

    No, it's not entirely in the compiler. It relies on some new interfaces such as INotifyCompletion and some framework implementation support such as AsyncTaskMethodBuilder. I don't believe there are any CLR changes required though.

    The compiler does a lot of work, building a state machine - it just refers to a few of those types within the state machine. Oh, and a lot of the Task-related types were significantly modified primarily for performance reasons.

    I have a series of blog posts which were initially written against the CTP but only using vanilla .NET 4 and some classes I whipped up myself. They won't work against the production implementation (as things changed a bit over time) but they'll give you a general impression of what's going on behind the scenes.

    0 讨论(0)
提交回复
热议问题