I have the following code options:
foreach (var e in result.ExcludedEntity)
await ProcessExcl.processEntity(e, e.ExclusionIdentification.UeiDuns);
await Task.WhenAll(result.ExcludedEntity.Select(async e =>
await ProcessExcl.processEntity(e, e.ExclusionIdentification.UeiDuns)));
I realize the first one will run synchronously and the second will be asynchronous.
Is there a way to limit the second to by say running in batches of 20 (I don't even know if that is ideal)?
But I can tell you that running them all at once (sometimes 7000 results) runs slower than running it synchronously.