dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

GetAwaiter() Remarks Are Not Clear

Open Yashuaa opened this issue 2 years ago • 4 comments

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:

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

Yashuaa avatar Jun 14 '23 01:06 Yashuaa

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Jun 14 '23 01:06 ghost

Tagging subscribers to this area: @dotnet/area-system-threading-tasks See info in area-owners.md if you want to be subscribed.

Issue Details

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:

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

Author: Yashuaa
Assignees: -
Labels:

untriaged, Pri3, area-System.Threading.Tasks, needs-area-label

Milestone: -

ghost avatar Jun 15 '23 14:06 ghost

We should delete those comments from the awaiters from Task and Task<TResult>. They're no longer accurate.

stephentoub avatar Jun 27 '23 03:06 stephentoub

Did anyone ever get on this ?

Yashuaa avatar Aug 27 '24 12:08 Yashuaa