Cancellation Tokens on Async Methods#3449
Cancellation Tokens on Async Methods#3449Narnian12 wants to merge 2 commits intoFirelyTeam:developfrom
Conversation
…optional cancellation tokens
|
I think this needs the |
ewoutkramer
left a comment
There was a problem hiding this comment.
Just one (minor) question about code duplication...
| ///<inheritdoc/> | ||
| public ResolverResult TryResolveByUri(string uri) | ||
| { | ||
| if (uri == null) throw Error.ArgumentNull(nameof(uri)); |
There was a problem hiding this comment.
Should we implement this by calling the async version and blocking on it? I am trying to avoid the code duplication here....
|
About the breaking change.... I thought we could just add an optional param to the interface, but we cannot as existing clients would still break. But we can use default implementations: interface X
{
// New signature
int Calculate(int a, int b, CancellationToken ct) =>
Calculate(a,b);
// Existing signature
int Calculate(int a, int b);
}We cannot do a breaking change until SDK7, which is probably almost 2 years out.... |
That makes sense, thanks! I can abandon this PR and make another one that overloads the original methods, so we don't have breaking changes. Or if there are more pressing issues to contend with, I can take a look at those as well. |
|
I think it's fine to continue here, you'll just need to restore the original interface method and use default implementation for the new one that calls the original - and maybe some adjustments to implementers if necessary, maybe not :) |
Description
IAsyncResourceResolverasync methodsCancellationToken.None(default) by defaultCommonWebResolver.TryResolveByUriAsync()HttpClient.SendAsync()Related issues
Resolves #3081.
Testing
MultiResolverandWebResolver- wrappingCommonWebResolverwith the async method honoring the tokenFirelyTeam Checklist