dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.29k stars 5.92k forks source link

Bad await FromResult examples #43094

Open olivier-net opened 1 month ago

olivier-net commented 1 month ago

Type of issue

Missing information

Description

There are 2 places in the page where it does return await Task.FromResult(new User() { id = userId }); await and Task.FromResult are the opposite, the should not be use together.

Also, there are no example on what to do if the method is synchronous but must return a Task, ex: when implementing an interface.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-scenarios

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/asynchronous-programming/async-scenarios.md

Document Version Independent Id

77bdee53-c2a0-e16f-c93a-3ca0afae0b93

Article author

@BillWagner

Metadata

Related Issues

BillWagner commented 1 month ago

hi @olivier-net

This is an area that needs more work.

Short answers to your comments: