I plan to work using the hangfire.io library, and I can observe its processing in the built-in panel. However, my system has a requirement that the task can be canceled from the toolbar.
It is possible to delete the current task, but this only changes the state of the task in the database and does not stop working.
I see that the documentation has the option to pass the IJobCancellationToken , however, as I understand it, it is used to stop the job correctly when the entire server is disconnected.
Is there a way to achieve a program cancellation of an already running task?
Do I have to write my own component that periodically displays the database and checks if the current instance of the server is running a job that has been canceled? For example, maintain the dictionary jobId -> CancellationTokenSource, and then cancel the signal cancellation using the appropriate token.
source share