-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Task.WaitAsync methods #48842
Add Task.WaitAsync methods #48842
Conversation
Tagging subscribers to this area: Issue DetailsNote that #47525 api-approved a different surface area, but we will rediscuss next week instead using the revised proposal, which this PR implements. If we instead decide to stick with what was approved, I'll replace this with stephentoub@a91eb11, which has the same guts but different public APIs exposing it. For now, I'm marking it no merge until the revised surface area is approved.
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs
Outdated
Show resolved
Hide resolved
Implementation LGTM, but I'm also having second thoughts about the |
Pinging @dotnet/ncl since the change touches networking product code as well. |
Yup ;-) |
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
Outdated
Show resolved
Hide resolved
8b4e38e
to
1513edd
Compare
src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs
Show resolved
Hide resolved
src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, all I've found were really minor nits ;)
Thank you @stephentoub !
src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs
Show resolved
Hide resolved
src/libraries/System.ComponentModel.EventBasedAsync/tests/BackgroundWorkerTests.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs
Outdated
Show resolved
Hide resolved
1513edd
to
9a84af8
Compare
src/libraries/Common/tests/System/Threading/Tasks/TaskTimeoutExtensions.cs
Outdated
Show resolved
Hide resolved
9a84af8
to
20557fd
Compare
20557fd
to
da10cce
Compare
Waiting for the WaitAsync().Wait() bugs to be filed 🤣 |
This seems more akin the It should be called just /cc @stephentoub |
We explored lots of options and names. I think "When" is strictly worse than where we landed. |
Why is |
It's not. SemaphoreSlim, for example, has Wait and WaitAsync methods. "When" only shows up in the static WhenAny and WhenAll, where is about one or all of the arguments completing. That's not the case here, where it's an instance method that's about waiting for the instance, just asynchronously, just as with SemaphoreSlim.WaitAsync, and with the wait curtailed by the arguments, just as with Wait. "When" makes it sound like the operation won't complete until the timeout or cancellation is requested, which is not the case. |
My understanding of the general guidance is that The exceptions to this rule are methods operating on |
That's exactly the same case here.
Those are all statics. This is not. It is the asynchronous version of the synchronous Wait, just as with SemaphoreSlim. Async isn't used in the statics on task because it's deemed redundant in that context; it's not here. |
Got it! |
I know I'm coming in late here, but @stephentoub any chance you can provide a control option to honor custom TaskSchedulers? Presently ConfigureAwait(false) suppresses both executioncontext capture and taskscheduler capture. Hoping some day that the default will permit custom schedulers for applications that need some control over thread scheduling (e.g. to implement quotas) |
Fixes #47525
Fixes #27722
Note that #47525 api-approved a different surface area, but we will rediscuss next week instead using the revised proposal, which this PR implements. If we instead decide to stick with what was approved, I'll replace this with stephentoub@a91eb11, which has the same guts but different public APIs exposing it. For now, I'm marking it no merge until the revised surface area is approved.