[C#] Generate async methods with CancellationToken support
More of a feature request than an issue. Would it be possible to generate async methods with CancellationToken support?
@jonsa do you mean a method to submit a HTTP request to cancel/void a token somehow?
No I don't, I think? :)
Async methods are usually implemented in two flavors
public Task MyAsync(object arg1, object arg2)
{
return MyAsync(arg1, arg2, CancellationToken.None);
}
public Task MyAsync(object arg1, object arg2, CancellationToken cancellationToken)
{
// ...
}
And so does RestSharp RestClient.
What I'd like is for the generated client to use the async methods with CancellationToken support.
I haven't found the time to fully understand what it would take to implement but I've looked around a little to get a sense of it. The way I picture it, it is quite a simple refactoring process.
- Any current async method should take an additional CancellationToken argument and be used when using the RestSharp client.
- Recreate the previous async method which calls the newly created one by passing all arguments and CancellationToken.None
@ozziepeeps @wing328 - it looks like the above PR was never merged, and we still don't have CancellationToken support in Swagger. What is the current status?
Hi @smflorentino, you are welcome to merge the PR if it meets your needs. Thanks
Is there any reason, why the PR is not yet merged, but closed?
Any update on when this will be available? It's cumbersome ot add the CancellationTokens manually.