public void Do_WaitsForThrottlersForSameGroupingsAndDoesNotWaitForDifferentGroupings() { var throttler = new MultipleGroupThrottler<int>(); throttler.AddConcurrencyLimiter(e => e % 2, 1); var task1 = throttler.Do(async () => await Task.Delay(300), 0); var task2 = throttler.Do(async () => await Task.Delay(200), 1); var task3 = throttler.Do(async () => await Task.Delay(200), 1); task1.Wait(); task2.IsCompleted.ShouldBeTrue(); task3.IsCompleted.ShouldBeFalse(); }
public void Do_WaitsOnThrottlersForTheSameGrouping() { var throttler = new MultipleGroupThrottler<int>(); throttler.AddConcurrencyLimiter(e => 1, 1); var task1 = throttler.Do(async () => await Task.Delay(400), 1); var task2 = throttler.Do(async () => await Task.Delay(200), 1); var task3 = throttler.Do(async () => await Task.Delay(100), 1); task1.Wait(); task2.IsCompleted.ShouldBeFalse(); task2.Wait(); task3.IsCompleted.ShouldBeFalse(); }