Timer set to single , keeps firing

Windows, 2015 R3
I have a timer which is set to timer.modesingle
and it keeps firing
To shut it up I have to set it to enabled = false

Is this a known issue ? (One of these situations where someone would say ‘check Feedback’, but it doesnt work if you dont have bang-up-to-date Xojo)

I use timers heavily in Windows, and they behave themselves… I don’t recall them ever being a problem back in 2015 at all.

Here’s something you can try: set a breakpoint in the action of the timer, and use the debugger to inspect the timer to see what it thinks it’s mode is. It is possible you have inadvertently set it to modeMultiple somewhere…

One other thought: if the debugger indicates that the mode is single on the timer, but it keeps firing, then search the project for the timer to see everywhere in code that you are touching that timer. Something is setting it off multiple times.

I would step through the timer and what happens after it to see if something is enabling it again. Something other than the mode seems to be re-firing the timer when you are not intending to. Had that happen before and the only way I could find it was to step through the timer event and then the events after it exits the timer.

Are you doing anything to the time itself from within it’s action event ?

Nope.

This was the one line of code in the app which did anything with the timer:

'//keep resetting the timer so it only fires once resizetimer.Mode = 1

That code is in the Resized event of a document window.
Why?
Some years back I noticed the Resized event firing WAY too many times on the Windows build, and so I delayed reacting to (say) 10 resized events by setting a timer: when the timer fires, the screen repaints.

I am sure that at one time, this worked as designed, setting the mode basically ‘reset the clock’ and the timer fired once, seconds after the most recent mode setting.

It now looks as if it fires every time, and the Resized event still happens too often.

This only affects the Windows build. The Mac build of the same code and same Xojo version works fine.
That means the issue is either Windows itself, or a subtle difference in the events that happen in Windows.
I have a solution now by making the timer disable itself in the action event.
The Resized event now sets the mode and enables the timer.

This is how I would do it.

resizetimer.Mode = Timer.ModeOff resizetimer.Mode = 1

[quote=382126:@Michel Bujardet]This is how I would do it.

resizetimer.Mode = Timer.ModeOff resizetimer.Mode = 1[/quote]
Possibly the other way round?

And that is essentially what I did.
Shouldnt have been needed, but it works

To properly reset the timer, you got to set it off first. So it won’t fire and start with the period from that point.

BTW, it would be nice if you clicked my post as answer. TIA

If you like.
I had already come up with that as a workaround and applied it …

Thank you.