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

DispatcherTimer.Tick can be executed when the timer is not running #15626

Open
TomEdwardsEnscape opened this issue May 6, 2024 · 1 comment
Labels

Comments

@TomEdwardsEnscape
Copy link
Contributor

Describe the bug

When DispatcherTimer elapses, it enqueues a callback on the UI thread. But other code can execute on the UI thread before that callback is executed. This other code can disable the timer, and reasonably expect that the callback will not be executed. But because the callback has already been added to the dispatcher's queue, it is unexpectedly executed.

To Reproduce

There is no way to precisely reproduce the issue, because it's a race condition.

Expected behavior

DispatcherTimer.Tick is never executed when DispatcherTimer.IsEnabled is false.

Avalonia version

master

OS

No response

Additional context

I worked around this issue in #15596. I didn't want to make a low-level change to timers for that PR.

@maxkatz6
Copy link
Member

maxkatz6 commented May 7, 2024

cc @kekekeks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants