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
WithCancellationextension 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.