diff --git a/src/libraries/Common/tests/System/TimeProviderTests.cs b/src/libraries/Common/tests/System/TimeProviderTests.cs index 119a35610f1f5..e0840f09d1cdb 100644 --- a/src/libraries/Common/tests/System/TimeProviderTests.cs +++ b/src/libraries/Common/tests/System/TimeProviderTests.cs @@ -143,7 +143,9 @@ public void TestProviderTimer(TimeProvider provider, int minMilliseconds) state.TokenSource.Token.WaitHandle.WaitOne(Timeout.InfiniteTimeSpan); state.TokenSource.Dispose(); - Assert.Equal(4, state.Counter); + // In normal conditions, the timer callback should be called 4 times. Sometimes the timer callback could be queued and fired after the timer was disposed. + Assert.True(state.Counter >= 4, $"The timer callback was expected to be called at least 4 times, but was called {state.Counter} times"); + Assert.Equal(400, state.Period); Assert.True(minMilliseconds <= state.Stopwatch.ElapsedMilliseconds, $"The total fired periods {state.Stopwatch.ElapsedMilliseconds}ms expected to be greater then the expected min {minMilliseconds}ms"); }