Running Jobs One At A Time

I am currently using Hangfire’s Enqueue functionality to fire background task which is working like a dream! However, I would like to allow one job to finish before starting another.

I can’t find in the documentation if there is a way to queue up jobs in such a way that allows on task to complete before another one can run. Could anyone provide any guidance?


You can enqueue Continuation Jobs:

var firstJobId = BackgroundJob.Enqueue(() => doSomething());
var secondJobId = HangfireServer.ContinueWith(firstJobId, () => thenDoThis());