Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future Checks don't always get disabled #4

Closed
corbob opened this issue Aug 30, 2021 · 0 comments · Fixed by #5
Closed

Future Checks don't always get disabled #4

corbob opened this issue Aug 30, 2021 · 0 comments · Fixed by #5
Assignees
Labels
Milestone

Comments

@corbob
Copy link
Member

corbob commented Aug 30, 2021

While working to reproduce and debug chocolatey/choco#2289, @vexx32 found this handy note about Timer.Dispose:

Callbacks can occur after the Dispose() method overload has been called, because the timer queues callbacks for execution by thread pool threads. You can use the Dispose(WaitHandle) method overload to wait until all callbacks have completed.

If we are interpretting this correctly, what this is saying is that even though we dispose of the timer in DisableFutureChecks(), we don't guarantee that it'll never fire.

Further, the remarks for Timer.Change state:

If dueTime is Timeout.Infinite, the callback method is never invoked; the timer is disabled, but can be re-enabled by calling Change and specifying a positive value for dueTime.

If period is zero (0) or Timeout.Infinite, and dueTime is not Timeout.Infinite, the callback method is invoked once; the periodic behavior of the timer is disabled, but can be re-enabled by calling Change and specifying a positive value for period.

Which to me says that to disable the Timer, you can Change it with a dueTime of Timeout.Infinite and a period of Timeout.Infinite.

@corbob corbob self-assigned this Aug 30, 2021
@corbob corbob added the Bug label Aug 30, 2021
corbob added a commit to corbob/rhino-licensing that referenced this issue Aug 30, 2021
Set the timer to infinite timeout so that it actually disables the
timeout.
Disable Future Checks when license is invalid. Calling this prior to
checking for expired license as the timer will still throw an exception
even when expired.
corbob added a commit to corbob/rhino-licensing that referenced this issue Sep 7, 2021
Set the timer to infinite timeout so that it actually disables the
timeout.
Disable Future Checks when license is invalid. Calling this prior to
checking for expired license as the timer will still throw an exception
even when expired.
@vexx32 vexx32 closed this as completed in #5 Oct 13, 2021
vexx32 added a commit that referenced this issue Oct 13, 2021
(#4) Ensure future checks are disabled when expected
@gep13 gep13 added this to the 1.4.1 milestone Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants