Is it safe to have nested BackgroundJobs enqueued?
For example:
BackgroundJob.Enqueue(x => x.CalculateAll(myId));
public void CalculateAll(int id) { var myList = _repo.GetMyList(id); foreach (var item in myList) BackgroundJob.Enqueue(x => x.DoDiffCalculation(item.id)); }
That’s a totally fine thing to do. In the end DoDiffCalculation is executed all on its own so the job is not nested in the way you might think by looking at the code.
What if the nested one failed / delayed for any reason, would it hold the parent job?
Or both are being executed with a seperate / new instance of BackgroundJob?