I've landed here with more or less the same question. We enqueue long-running jobs in Hangfire. There is no "Cancel" button for jobs in the built-in dashboard, only a "Delete" button.
Using that Delete button will remove the Job from the running jobs in the built-in dashboard (near) instantly. And once the running job checks for cancellation to exit it'll actually exit with an OperationCancelledException.
However, consider the case where a job either (a) fails to nicely check for cancellation or (b) somehow got stuck because of a coding error: now the job keeps running, even though the built-in dashboard suggests it is already "Deleted".
I'm pretty new to working with Hangfire in detail, but I had expected instead of a "Deleted" button, to get these:
- "Request Cancellation": this would cancel the job as soon as it checks for cancellation, and only once it actually does so /exits will it move to the "Deleted" (or similar) list.
- "Force Stop": this would be the kill-switch, aborting the process ungracefully, but again only moving it to the "Deleted" (or similar) list once it actually was killed.
I'm unsure if posting here is wise. I considered opening an issue on Github as well as starting a new thread, but my thoughts seemed enough related to the OP that I ended up posting here. Suggestions to repost my ramblings elsewhere are also welcome.