How background jobs run?

queues
Tags: #<Tag:0x00007f49a6dc5540>

#1

If I have created job like below:
BackgroundJob.Enqueue(() => Console.WriteLine(“first”));
BackgroundJob.Enqueue(() => Console.WriteLine(“second”));
BackgroundJob.Enqueue(() => Console.WriteLine(“third”));


How theses job is going to run? Are they goin run in the order,? Or they are going run concurrently?
If they run concurrently not in order, then how to create jobs which runs in order, one after other.

Please guide me here.


#2

If you need to ensure an order you can use Continuations. https://www.hangfire.io/overview.html

I’m on mobile or I’d post examples of my own.


#3

Can you please, post one example on running jobs in order. Another job should not start until previous finished running.


#4
string jobId = BackgroundJob.Enqueue(() => Console.WriteLine(“first”));

BackgroundJob.ContinueWith(
jobId,
() => Console.WriteLine(“second”));

#5

Awesome, Thank you very much for time and support.