Allow PeriodicTimer to have an infinite timeout (#82986)
authorStephen Toub <stoub@microsoft.com>
Mon, 6 Mar 2023 21:40:15 +0000 (16:40 -0500)
committerGitHub <noreply@github.com>
Mon, 6 Mar 2023 21:40:15 +0000 (16:40 -0500)
commit8ae17dbfba3ae15c35dd3762f4e446a35b07ea83
tree950ae0f96eb113acaf3d3512fe7262a1a8ff1735
parentd39dbacfc2d09f2aeb5c2b2548b973edd27b50cd
Allow PeriodicTimer to have an infinite timeout (#82986)

* Allow PeriodicTimer to have an infinite timeout

When PeriodicTimer was introduced, we prohibited infinite timeouts as they made no sense: you couldn't change the period after construction, so creating a PeriodicTimer with an infinite timeout meant creating an instance that would never tick.  But now that we've added a Period property with a setter that allows changing the period, infinite timeouts do make sense: as with Timer, they can be used as a mechanism to stop and start the timer, e.g. creating the PeriodicTimer with infinite and only in response to some later action updating its Period to start it.

* Update PeriodicTimer.cs
src/libraries/System.Private.CoreLib/src/System/Threading/PeriodicTimer.cs
src/libraries/System.Runtime/tests/System/Threading/PeriodicTimerTests.cs