Skip to content

Instantly share code, notes, and snippets.

@chadly
Created May 6, 2020 20:01
Show Gist options
  • Save chadly/23878399bda4a44240345633745a29bf to your computer and use it in GitHub Desktop.
Save chadly/23878399bda4a44240345633745a29bf to your computer and use it in GitHub Desktop.
process items
List<Task> tasks = new List<Task>();
for (int i = 0; i < parallelTaskCount; i++)
{
tasks.Add(Task.Run(async () =>
{
try
{
await ProcessScopeAsync(provider.CreateScope());
}
catch (Exception ex) when (Job.Config.Execution.HandleExceptions)
{
logger.LogError(ex, $"Unhandled exception in {nameof(ExecutionBase<TConfig, TItem>.ProcessScopeAsync)}");
}
}));
}
await Task.WhenAll(tasks);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment