Job 1 is scheduled to run every 5 minutes, and takes ~1 minute to complete.
A lot of work piles up and Job 1 takes 15 minutes to run.
There are now three Job 1's being processed concurrently - I don't want this.
Is there Hangfire setting, or do I need to poll job statuses manually?
Hangfire is an open-source framework that can be used to perform background processing in . Net and . Net Core applications. It is mainly used to perform background tasks such as batch/email notification, batch import of files, video/image processing, database maintaining, file purging, etc.
If anyone here is familiar with hangfire how can I stop the process through task manager? Then call <server>. WaitForShutdown() to wait until it's finished. This should allow any tasks currently processing to finish.
Batch jobs will help to build more complex workflows with Hangfire. They will give you the power of parallel processing and continuations, you can look at this code snippet: BatchJob . Create(x => { x.
The idea is, on a loading page, there is an email input field. Once the user writes his email and clicks the Get Email button, a background job should trigger. It will check if the transaction is complete, and once it is, it will send an email to the user.
You can use DisableConcurrentExecution attribute to prevent multiple executions of a method concurrently. Just put this attribute above your method -
[DisableConcurrentExecution(timeoutInSeconds: 10 * 60)]
public void Job1()
{
// Metohd body
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With