Hello to everyone,
I’m currently using hangfire on my web application to schedule recurring jobs the following way
from controller i recive all that i need to build a cron expression and tell hangfire wich method from a service called hangFireServices i want to execute
(my jobs are stored on the database and not the startup.cs file)
_recurringJobManager.AddOrUpdate(id, () => _hangFireServices.methodName(), cron);
my method is very simple it just move files from one origin folder to another storage, one file at the time, why one at the time and not all at once? well for each file i have to do more stuff but it is not important what. Problem is that the amount of files is too large and thus the job takes too long and the job it is usually configured to execute every hour. the situation is this:
- the firs execution of my job starts at 8 am
- it’s 9am therefore is time for a new execution but first execution has not finished.
- before starting the new executed which cannot be posponed i need to stop the first execution this without deleting the job because it still needs to execute every hour
also, end user wants to be able to stop the execution by pressing a button or something like that.
is there a way of doing this? some post mentioned the use of cancellation token but i don’t know how to trigger this for jobs that are already running.