Re:Async2 – The .NET Runtime Async experiment concludes
by pjmlp on Friday August 23, 2024 @01:31AM
(#41326419)
The kind of scenarios where this kind of interop is put to test is when old code, without being recompiled, takes a subclass, an interface implementation, a member reference, a delegate, or a lambda, compiled with async2 model, as parameter, and everything works as expected.
Something that I hope they take into account, having new code calling into the old code, is the easy part of the problem.
Re:Async2 – The .NET Runtime Async experiment concludes
by andygocke on Friday August 23, 2024 @12:20PM
(#41330307)
Yes, we considered that and implemented a solution. Effectively, the runtime will generate thunk methods that will invisibly bridge between the two worlds. Calling (and overriding) regular async methods with runtime async methods will be stitched up by the runtime. The user will never see the difference.
This means that all existing libraries will continue working as is, and newly written or existing code that is compiled against e.g. C# 14/.NET 10(?) can automatically opt into new mechanism without user intervention. The write-up does cover the considerations for interoperability between these two models as well.
In fact, this will make using async from other CIL-based languages much easier as the burden of capturing the state and suspending/resuming the execution will be on the runtime rather than language compiler authors.