public async void CanWaitForCounter() { var metrics = new InMemoryMetricsClient(); metrics.StartDisplayingStats(TimeSpan.FromMilliseconds(50), _writer); Task.Run(() => { Thread.Sleep(50); metrics.Counter("Test"); metrics.Counter("Test"); }); var success = await metrics.WaitForCounterAsync("Test", TimeSpan.FromMilliseconds(500), 2); Assert.True(success); Task.Run(() => { Thread.Sleep(50); metrics.Counter("Test"); }); success = await metrics.WaitForCounterAsync("Test", TimeSpan.FromMilliseconds(500)); Assert.True(success); success = await metrics.WaitForCounterAsync("Test", TimeSpan.FromMilliseconds(100)); Assert.False(success); Task.Run(() => { Thread.Sleep(50); metrics.Counter("Test", 2); }); success = await metrics.WaitForCounterAsync("Test", TimeSpan.FromMilliseconds(500), 2); Assert.True(success); success = await metrics.WaitForCounterAsync("Test", TimeSpan.FromMilliseconds(500), 1, async() => await metrics.CounterAsync("Test")); Assert.True(success); Task.Run(() => { Thread.Sleep(50); metrics.Counter("Test"); }); success = metrics.WaitForCounter("Test", TimeSpan.FromMilliseconds(500)); Assert.True(success); metrics.DisplayStats(_writer); }