Processing BackgroundJob One at a time


We want to process BackgroundJob one at a time/sequentially, i.e. only starts processing the next BackgroundJob if the current one is completed or failed.
So If there are 3 jobs queued, task1 is processed first, once task1 is completed/failed, task2 is processed, once task2 is completed/failed, task3 is processed.

Is using a workerCount of 1 when initializing Hangfire
the correct way to do this ?


Continuations are currently under development. They are almost done and will be shipped with Hangfire 1.4.0. The API will look like:

var parentId = BackgroundJob.Enqueue(() => Console.Write("Hello, "));
BackgroundJob.ContinueWith(parentId, () => Console.WriteLine("world!"));

The output will be deterministic, i.e. always the following:

Hello, world!