Fix infinite timeout passed to CancellationTokenSource.CancelAfter (#84009)
authorStephen Toub <stoub@microsoft.com>
Tue, 28 Mar 2023 10:24:48 +0000 (06:24 -0400)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 10:24:48 +0000 (06:24 -0400)
commit3231e4fbfbef268b1647bf6f695e6b42cfb2117d
tree159c0122b7c5a993e131ff358a8dfb0e857fbc38
parented921eef0bcbdf877d0f34f3bc47aa8aafcdbc81
Fix infinite timeout passed to CancellationTokenSource.CancelAfter (#84009)

The recent change to introduce ITimer broke CTS.CancelAfter(Timeout.InfiniteTimeSpan).  The TimeSpan's milliseconds were extracted as a uint but then ended up being cast to a long, such that rather than representing -1 milliseconds, it represented 4294967295 milliseconds.  With the uint representation in Timer, Timeout.UnsignedInfinite needs to be special-cased.
src/libraries/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs
src/libraries/System.Threading.Tasks/tests/CancellationTokenTests.cs