Description
When a non-repeating timer ticks, the _enabled
field is set instead of the Enabled
property here, which does not null out the internal timer:
Then, when the Interval
or AutoReset
properties are set, the timer is reactivated because it does not check whether the timer is enabled:
Also, along with reactivating the timer the _enabled
field is not set even though the timer is now enabled, and Stop()
would not stop the timer because it's already not enabled.
Maybe the original intention was to set the Enabled
property to false upon tick, such that timer != null
would also imply that the timer is enabled. It would be a breaking change to fix that part, but probably at least when the timer is activated the _enabled
field can also be updated such that it reflects the correct state.