This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ParallelTaskRunnerExtension | |
{ | |
public static void RunTasks(this IEnumerable<Task> tasks, int maxConcurrency, Action<Task> taskComplete = null) | |
{ | |
if (maxConcurrency <= 0) throw new ArgumentException("maxConcurrency must be more than 0."); | |
int taskCount = 0; | |
int nextIndex = 0; | |
var currentTasks = new Task[maxConcurrency]; | |
foreach (var task in tasks) |