Skip to content
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

Stopping the task by a cancellation token #3

Closed
poulad opened this issue Aug 25, 2017 · 3 comments
Closed

Stopping the task by a cancellation token #3

poulad opened this issue Aug 25, 2017 · 3 comments

Comments

@poulad
Copy link

poulad commented Aug 25, 2017

Is there a way to send a cancellation token to the task to stop it?

for example:

app.StartTask<SampleTask>(TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(5), source.Token);
@justdmitry
Copy link
Owner

Currently - no.

As a fast workaround, you may try to use token.Register with Action that stops task.

In all my use cases I start/stop tasks (a) never (b) only from administration page (during some maintenance).

What is your use case from stopping Task (stopping "forever", because cancellation token is not "undoable") with cancellation token?

@poulad
Copy link
Author

poulad commented Aug 25, 2017

@justdmitry My use case is cancelling the task for ever only after some async method(DoSomething()) finishes its job. I'd like to pass the cancellation token from DoSomething method to the task (SampleTask) runner. Then, DoSomething decides on when to stop the task (for ever).

@justdmitry
Copy link
Owner

Implemented in v5

justdmitry added a commit that referenced this issue Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants