This file contains hidden or 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
/// <summary> | |
/// Executes the given async delegates in parallel, | |
/// up to the given maximum degree of parallelism. | |
/// </summary> | |
public static async Task InvokeAsync(IEnumerable<Func<Task>> taskFactories, int maxDegreeOfParallelism) | |
{ | |
if (taskFactories == null) throw new ArgumentNullException(nameof(taskFactories)); | |
if (maxDegreeOfParallelism <= 0) throw new ArgumentException(nameof(maxDegreeOfParallelism)); | |
// Defensive copy. Similar to what Task.WhenAll/WhenAny does. |