private async Task WaitAndCount(int count, HostCacheManager cache) { for (int c = 0; c < 10; c++) { Interlocked.Increment(ref waiting); await cache.WaitToFetch(count.ToString(), Timeout.Infinite); Interlocked.Decrement(ref waiting); await Task.Delay(FetchoConfiguration.Current.MaxFetchSpeedInMilliseconds + 20); } }
public async Task CongestionTest() { SetupBasicConfiguration(); var cache = new HostCacheManager(); var l = new List <Task>(); var t = ReportStatus(); for (int i = 0; i < 10000; i++) { l.Add(WaitAndCount(i, cache)); } await Task.WhenAll(l); Assert.IsFalse(t.IsFaulted); }