Are (Xojo.Core)Timer Stacks inverted on macOS vs. Windows?

Excuses for the somewhat unclear title, but now that I have caught your attention, maybe you can help me clear up a confusion:

I am working on a desktop app that makes use of a mySQL database. To unblock the GUI while the app loads some pieces from the db, I moved a few selects into threads. One of them has to fill a listbox, so I iterate over the recordset, build an array of strings from the content and forward it via Xojo.core.timer.calllater to a method that takes this array, adds a row to the listbox and fills certain cells with the array content.
At the end another method is invoked by a calllater call that sets the listbox.listindex to 0 which triggers some functions.

So far, everything works nicely and makes the GUI a lot snappier. On macOS.

You might understand my surprise when I found that Listbox under Windows is filled in the wrong order.
I thought I had the select somewhat wrong and added an “order by”. No change.

Other experiments resulted in a listbox that only had one row or outofbounds exceptions when I had moved the addrow routine to another Xojo.core.timer.called method that was supposed to be run first.
It wasn’t, and the reason I found is that Windows seems to stack Calllater calls in a first in – last out manner, whereby macOS handles them first in – first out.
The recordset was perfectly ok. It were the calllater methods that did not get executed during the thread run and afterwards were processed in reversed order. When I inserted breakpoints I could verify their order in the debugger.

Did I skip this different behavior between both OS‘ in the docs? The only fix I found so far is to add a lot of Thread Sleeps which is of course the opposite of what I wanted to achieve. Or did I make a silly mistake?

I recently hit what I think is the same thing. I had developed the app under macOS which worked as I expected, then also compiled for Windows where it did not. In my case instead of add thread sleeps, what I did was switch from using a 0 or 1 ms wait time on the call to use 0 on my first call then progressively somewhat longer (but still subsecond) wait times after that. That seemed to help sequence them without adding any noticeable delay. But I didn’t do enough testing to make sure it always worked. It was basically a one-off thing with a short app life cycle. So I went for a Q&D workaround.

Thanks, Douglas! I’ll set up a demo project for a Feedback entry.

Somehow I’ve thought “hmm - haven’t I read this before”?
And indeed - I found the old Forum Thread about the same issue (at least, I guess so).

[quote]@Jon Ogden: So in OS X, the timers seem to fire in a FIFO pattern. So the end result is that window with a value of mIndex = 0 gets added to the mWallWindows array first, the second gets added on second, et.
In Windows, it appears the timers fire in a LIFO pattern. This screws up my array and the window with the largest index gets added to the array first.[/quote]
Maybe you want to add the other Forum Thread to your feedback://showreport?report_id=52208, so that Xojo is aware this causes unexpected issues to more than just a single user.

Despite Autocorrect changing your first name, I added the info.
Thanks a lot, Jürg!