In a foreach
loop I am using Task.Run
, to call a method to do some lengthy operations for each element.
The method I'm calling is an asynch method, but for my purpose, I'm not interested in the return, and I want to return other information to the client.
The problem is that only the quickest call completes and the others are ignored. How could I make sure that each call is called separately on its own thread, without blocking the rest of the code from executing and returning?
foreach (var job in Jobs)
{
Task.Run(() => _service.DoLongAsyncCall(job)
}