4 ms·
I don't think the author has experience working with C# tasks. Technically, the API documentation indeed says a Task has Start() methods i.e. is lazy. But pra
by Const-me 9y ago
I don't think the author has experience working with C# tasks.
Technically, the API documentation indeed says a Task has Start() methods i.e. is lazy.
But practically, in the majority of cases they are created already in Running or WaitingToRun state. This applies to tasks returned by asynchronous APIs in the framework, tasks implemented by user-written async methods, and tasks started with Task.Run() static methods. Calling Start() on them will throw an exception complaining about the wrong task state. So, in the current versions of .NET, the tasks are eager just like in JS.
I think the lazy tasks are mostly for backward-compatibility with older .NET framework 4.0 that already had tasks but didn’t support async-await.