I have an async job that does a lot of parallel awaiting of tasks. It does things like this:
var pupilsTasks = schools.Select(async school =>
{
var q = service.CreatePupilQuery();
await q.WhereSchoolIs(school);
var pupils = await q.Execute();
return pupils;
});
var pupilLists = await Task.WhenAll(pupilsTasks);
Mostly it’s working just fine, but very occasionally I find that the job has been running for many hours and never completes. (Normally the job should take less than a second to run.)
So my guess is somehow it’s deadlocking.
Is there anything specific I need to watch for when using async/await within a Hangfire job?