coravel icon indicating copy to clipboard operation
coravel copied to clipboard

Is there a way to cancel an invocable (not queued)?

Open fullstacktate opened this issue 4 years ago • 3 comments

I can see that when implementing ICancellableTask from the invocable, we get a Token. IScheduler exposes "CancelAllCancellableTasks", is there a way I can cancel a task specifically? (by name?).

The queue invocables allow us to deconstruct the tuple, is there something similar for none queues?

Thankyou for the awesome project!

fullstacktate avatar Dec 01 '21 17:12 fullstacktate

No, all invocables that are registered via the scheduler are all tied to the same cancellation token, which is triggered upon app shutdown.

What's the scenario you're looking to do?

jamesmh avatar Dec 22 '21 05:12 jamesmh

You could use C# CancellationTokenSource to do this.

Off the top of my head (this may not compile or make 100% sense), something like:

using var source = new CancellationTokenSource();

try {
   source.CancelAfter(TimeSpan.FromSeconds(30));
   // Do your stuff.
}
catch (OperationCanceledException)
{
   // Timeout occurred.
}

jamesmh avatar Jan 08 '24 13:01 jamesmh