4 ms·
>num += Calculate(20).Result; You're sure you should use .Result here instead of awaiting it?
by tester756 3y ago
>num += Calculate(20).Result;
You're sure you should use .Result here instead of awaiting it?
- uncheckederror 3y agoTo expand upon this thought, here is the AsyncGuidance doc[1] on why not to use .Result to get the return value of a completed Task in C#. To make this simple they introduced async Main[2] a few years ago. [1]: https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#asynchrony-is-viral https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/b... [2]: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-7.1/async-main.md https://github.com/dotnet/csharplang/blob/main/proposals/csh...