Skip to content

Commit cd7d006

Browse files
authored
Fix the TimeProvider test (#85268)
* Fix the TimeProvider test * remove the assert
1 parent 41cc61e commit cd7d006

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/libraries/Common/tests/System/TimeProviderTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void TestProviderTimer(TimeProvider provider, int MaxMilliseconds)
140140
state,
141141
TimeSpan.FromMilliseconds(state.Period), TimeSpan.FromMilliseconds(state.Period));
142142

143-
state.TokenSource.Token.WaitHandle.WaitOne(60000);
143+
state.TokenSource.Token.WaitHandle.WaitOne(Timeout.InfiniteTimeSpan);
144144
state.TokenSource.Dispose();
145145

146146
Assert.Equal(4, state.Counter);
@@ -499,7 +499,14 @@ public bool Change(TimeSpan dueTime, TimeSpan period)
499499
period = new TimeSpan(period.Ticks / 2);
500500
}
501501

502-
return _timer.Change(dueTime, period);
502+
try
503+
{
504+
return _timer.Change(dueTime, period);
505+
}
506+
catch (ObjectDisposedException)
507+
{
508+
return false;
509+
}
503510
}
504511

505512
public void Dispose() => _timer.Dispose();

0 commit comments

Comments
 (0)