I would like to use CancellationToken
from .net core.
I passed it instead IJobCancellationToken
like this:
public void LongRunningMethod(CancellationToken cancellationToken)
{
for (var i = 0; i < Int32.MaxValue; i++)
{
cancellationToken.ThrowIfCancellationRequested();
Thread.Sleep(TimeSpan.FromSeconds(1));
}
}
start
BackgroundJob.Enqueue(() =>LongRunningMethod(CancellationToken.None));
and it works fine, but i can’t stop this job using this:
BackgroundJobClient.Delete("this_job_id")
Is there any way to do this?