public static async Task StartStopAsync() { using var counter = new Counter(); using var timer = new AsyncTimer(counter.Run); True(timer.Start(TimeSpan.FromMilliseconds(10))); True(counter.WaitOne(DefaultTimeout)); True(timer.IsRunning); False(await timer.StopAsync()); False(timer.IsRunning); var currentValue = counter.Value; True(currentValue > 0); //ensure that timer is no more executing await Task.Delay(100); Equal(currentValue, counter.Value); }
public static async Task StartStopAsync() { var counter = new Counter(); using (var timer = new AsyncTimer(counter.Run)) { True(timer.Start(TimeSpan.FromMilliseconds(10))); await Task.Delay(100); True(await timer.StopAsync()); var currentValue = counter.Value; True(currentValue > 0); //ensure that timer is no more executing await Task.Delay(100); Equal(currentValue, counter.Value); } }