Trying to implement cancellation of tasks in a project and having a few problems understanding how the cancellation tokens actually work. I’m passing them into my methods and checking at different points along the way with token.ThrowIfCancellationRequested()
How do I actually cancel the job? I’ve had a bit of luck with deleting the job through the BackgroundJobClient.Delete(jobId) method, which seems to cause the OperationCanceledException, although this then marks the task deleted which is not quite what I wanted as I want these to be re-queue-able.
In short:
- Is there a way to cancel a job without deleting it?
- If not, are there plans to implement this?
- Am I even doing the right thing by using the Delete method to ‘cancel’ tasks?