Running jobs synchronously without Hangfire using IBackgroundJobClient implementation?

Hello,
I wanted to have the ability to run my application without the need to have HangFire running. (Mainly for local debugging).
I think I can achieve this by creating my own IBackgroundJobClient (I use this instead of static calls) which invokes actions immediately instead of queueing up within the Hangfire infrastructure. I’m intending to do this by executing the actions immediately inside of the Enqueue/schedule etc.

Ignoring the potential for different behaviour, is this approach valid? Is there a better/existing way to “switch off” hangfire but maintain execution of jobs?

Thanks in advance

I think that would be a lot of work. If you were looking for testing, I would suggest mocking the IBackgroundJobClient. If you want to debug, I would suggest changing the number of works to just one (1).

Hi @kris, I’m looking for a similar solution to a similar problem. Specifically when I’m running certain acceptance tests I want it to immediately invoke the action passed to IBackgroundJobClient#Enqueue. Did you ever come up with a solution to this problem and if so are you able and willing to share your code? Thank you in advance.