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?