dotnet / dotnet/dotnet-api-docs

GetAwaiter() Remarks Are Not Clear

Open
#9,064 4 comments 0 reactions 0 assignees View on GitHub
area-System.Threading.Tasks Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

I've seen multiple discussions in the issues section about the remark below

> This method is intended for compiler use rather than use directly in code.

For this specific method `GetAwaiter()` which is used like so:

```cs
var result = SomeAsyncMethod().GetAwaiter().GetResult();
```

So if devs shouldn't be using `GetAwaiter()` in code then we need to know, if there are 1 off situations when we should prefer `GetAwaiter().GetResult()` versus `.Wait()` - we need to know.

So the remark should either be removed or there should be clarification because at this point the stance from MSFT is "Don't use it" and that doesn't seem to be the case from @stephentoub 's comments.

I think the remark should just be removed altogether. It looked like someone tried to remove it but the PR got closed and never got merged.

It would be for here : https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.getawaiter?view=net-7.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.