DispatcherTimer.Tick
can be executed when the timer is not running
#15626
Labels
DispatcherTimer.Tick
can be executed when the timer is not running
#15626
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 whenDispatcherTimer.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.
The text was updated successfully, but these errors were encountered: