-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Async Functions with overload CancellationToken passed? #231
Comments
Mock Up example: ` try
|
What would you expect on cancelation? The only place we really wait is when we call the actual api so I guess a cancelation could ignore the result. I figure it would be easier to just kill the taks in the consuming application, that would have an immediate result |
In principle we should pass it on to HttpClient. It will then be able to cancel the network stuff, rather than just having it spew thread aborts or similar. |
It would allow us to have timeouts out of the box, but just passing a TaskCancellationSource with a cancelafter... :) |
Should not be too hard, just a bunch of overload to add |
Yea. I've begun work on it. |
Sweet. Yea, you can pass that token all the way to the HttpClient. Let the caller handle the TaskCanceledException. One of my fav parts of the Task Library. |
public Task MyMethod(CancellationToken t = default(CancellationToken)) Use that on all your normal calls. no need to create new methods. The compiler will handle creating the overloads for you. |
@LordMike -- Totally forgot about the extra benefit of the timeout. Yes, that will keep a UI from waiting for some other timeout within the API (bad internet connection, bad dns, etc). |
Any chance a future version will be able to take a CancellationToken on the Async ops? This way if a user is waiting on an operation, and they want to cancel it, it will stop it? I know it returns a Task on those functions, and you are leaning on the .Result for many of the functions. This way you can pass the token all the way down the stack. Following your source, it seems like it could be easily passed. You could add the optional param.
I know this is opensource, so I guess I could add it if desired. What is your thought on that?
Cool Lib BTW.
The text was updated successfully, but these errors were encountered: