-
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.WithCancellation(CancellationToken)
method
#27722
Comments
Similar code is already in corefx; but only used for running tests rather than exposed as api Task WithCancellation(this Task task, CancellationToken cancellationToken) Also Task WhenAllOrAnyFailed(this Task[] tasks)
Task WhenAllOrAnyFailed(this Task[] tasks, int millisecondsTimeout) |
for those not good at async, what difference? |
Cancelling the Cancelling the |
What would be a good name for that? |
|
That's actually an interesting idea. The upside is I think people would understand it better. The downside is that |
CC @stephentoub |
I really prefer the |
The
WithCancellation
extension method is super-useful. Should we add it to the .NET Framework / .NET Standard itself?The risk is that folks will misunderstand the subtle yet important difference between using this method and passing the CancellationToken into the original async method properly.
Preferably this is not an extension method so it doesn't conflict with extension methods that folks have already defined. It should just override them, assuming the semantics are equivalent (the type of exception thrown, etc.)
See also the source code for its definition in the vs-threading library.
As discussed in davidfowl/AspNetCoreDiagnosticScenarios#8 with @davidfowl.
The text was updated successfully, but these errors were encountered: