Search code examples
asp.net-corehangfire

Is it safe to call BackgroundJob.Enqueue from inside a RecurringJob?


I have a RecurringJob that receives some rows from a database and I want to send an email for each row. Is it safe to call BackgroundJob.Enqueue within the recurring job handler for each row to send an email?

My aim is to keep the work in the recuring job to a minimum.


Solution

  • It's a bit late to answer this but yes, you can call BackgroundJob.Enqueue() from within the recurring job. We use MongoDB and since it is thread safe, we have one job creating other jobs that run both serially and parallel.

    Purpose of background jobs is to perform a task whether you start from an API call, recurring job or the background job itself.