You didn’t specify which platform(s) you see this on. But if you are talking about macOS, you may be the victim of a “feature” called “app nap” where Apple tries to minimize resource usage (particularly battery, cpu, or active memory) and automagically put a GUI app to sleep while the window is not visible – i.e. minimized or fully covered by other applications.
And a long time ago, Apple exposed an easy way in the macOS SDK to disable that but later macOS SDK versions do not offer that anymore. You may find parts of this thread educational for ways to still disable it from your code.
Sorry for taking so long to get back. Busy busy.
Since in Catalina there is no “disable appnap” checkbox in “Get Info”, I opened Activity Monitor, and added the column AppNap. It shows whether an app sleeps without being the focused window. I had appnap = No.
I verified that my app doesn’t sleep no matter which of 100 windows I have open.
Oddly, I spent a few hours trying to make exactly this work yesterday.
Complete failure… no variation on the addhandler line would compile for me.
I added an invisible window to do the job, and it seems to work
This post suggests that sooner or later, it wont, as the window isnt visible.
Anyone have a working code example of a timer in code , that works under Xojo 2018 R3 (which Im using for my legacy projects)
Here’s what I do, in a method called from App.Open:
app.generalTimer = new Timer
app.generalTimer.enabled = True
app.generalTimer.RunMode = Timer.RunModes.Multiple // Ticks once per minute
app.generalTimer.period = 60000 // for the life of the app
AddHandler app.generalTimer.Action, WeakAddressOf app.generalTimerEvent
Thats the trick.
Quite obscure in the Xojo documentation…
In Xojo 2018 it turns out to be .mode rather than .runmode , with different enumeration too.
(Another one of those seemingly pointless language changes)