Jobs in Enqueue state, most never run

@KeithBarrows, if you are using instance methods, always use the .Enqueue<T> method overloads:

// This is for instance methods
/// Place [Queue] attribute to the IJob.Execute method
BackgroundJob.Enqueue<IJob>(x => x.Execute("payload"));

// This is for static methods
BackgroundJob.Enqueue(() => Program.Main());

Never use the following construct, as it even does not make any sense, because of unnecessary creation of the Job class instance.

// Don't do this at home
var job = new Job();
BackgroundJob.Enqueue(() => job.Execute());
1 Like