4 ms·
Is using the await keyword basically like a shortcut instead of having to add a callback method to an asyncworker and then get the result manually?
by chrisper 10y ago
Is using the await keyword basically like a shortcut instead of having to add a callback method to an asyncworker and then get the result manually?
- j_s 10y agoI am always curious which enhancements to C# are just syntactic sugar vs. requiring IL and/or CLR enhancements. Microsoft released the CLR code required for async/await separately, enabling back-compat for .NETv4.0. The F# language has supported it back to .NETv2.0. https://blogs.msdn.microsoft.com/bclteam/2012/10/22/using-asyncawait-without-net-framework-4-5/ https://blogs.msdn.microsoft.com/bclteam/2012/10/22/using-as...
- dgudkov 10y agoAsync in F# works quite differently from C#. This article highlights some key differences [1]. [1] http://tomasp.net/blog/csharp-async-gotchas.aspx/ http://tomasp.net/blog/csharp-async-gotchas.aspx/
- tucaz 10y agoIn short, yes.
- Matthias247 10y agoThe slightly longer story is also yes. But there are some optimizations and tricks. E.g. if the Task is already completed the async method will just continue to the next statement instead of attaching a continuation that will later be called. And in case continuations are used async await will automatically capture the current SynchronizationContext and will assure that the continuation runs on the same.
- maxxxxx 10y agoYes, and it pays off to know that. It explains a lot of behavior you will see.