-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
CancellationToken not working #339
Comments
I can't reproduce this. I tested against http://slowwly.robertomurray.co.uk/ and set that to 10 seconds. I cancelled my token after 5 seconds. It threw the TaskCancelledException just fine. |
@Cheesebaron Thanks. What kind of project is it? (Xamarin, console?) |
I tried in a NET Core console app. I can try in a Xamarin app too. |
You added the token to the Interface but did you add the actual token in the actual implementation of the method? I think you should be forced by the interface but nevertheless you can check that. |
@Cheesebaron See my update in the description at the bottom. Thanks |
@michelmoorlag I am calling with the token, yes. |
Meh, I was trying to compile from source code so I could try to debug, but it throws errors I can't figure out how solve
Not the best timing for the timeline of the tasks I have... |
Can't reproduce in a Xamarin Android project either. Just like you I have a "Core" which is NetStandard 1.6 with target fallback so forms can be installed. Refit is added in both core and droid project. Then I have two buttons, one for starting a task with a request. The other calling cancel on the CancellationTokenSource. Works fine, a TaskCancelledException is thrown and request seems to be cancelled too. |
You can see how I do it here: https://github.com/Cheesebaron/refitcancel works fine. As for building the source. I think you need VS2017 and Net Core 2.0 |
@Cheesebaron thanks. No idea what the heck is going on. I debugged couple of times my code and I am definitely passing the token parameter. |
It's worth to mention in the docs that |
The
CancellationToken
parameter defined in the interface does not seem to be used, when I callcancellationToken.Cancel()
it's not throwingTaskCanceledException
. The call runs until the end like when the method didn't have the parameter, or like it's ignoring it.To see this I am simulating low network speed.
According to #88, I just need to add a parameter of
CancellationToken
type to my interface.UPDATE: not sure if it matters, I have a Xamarin Android app and the code which calls Refit is in a NETLibrary 1.6. and I am using target fallback:
The text was updated successfully, but these errors were encountered: