In removing a few more lurking “ThreadAccessingUIException” states, I’ve discovered two that were not showing up except in a very specific scenario - the closing of a sheet window. Since this sheet can appear attached to any of 5 windows, creating an App-level global timer to close it is what I see as the proper solution.
Since I can’t drop a Timer onto the App class, what is the best way to create a Timer and define the callback on the action?
Is this logic correct:
In App class, add a new property:
tmCloseStandby As timer
In App.Open:
tmCloseStandby = New Timer
tmCloseStandby.Mode = 0
tmCloseStandby.Period = 2
AddHandler tmCloseStandby.Action, WeakAddressOf CloseWStandbySheetCB
A global method of CloseWStandbySheet containing:
Try
WStandbySheet.Close
Catch
// should I care here? The WStandbySheet will either be open or not
End Try
Then, in the other areas of the app I would call this to close the sheet window,:
Why dont you add the timer to the sheet window and let it close itself? If the period varies depending upon the calling window, set the period in the sheet windows constructor.
Interesting xojo.core.timer.CallLater runs on the main UI thread so it should have worked, must have been something else going on causing the issue. I’ve just dropped it into a simple test project running from a thread and it worked fine. Glad you got it sorted though Yes, xojo.core.timer.CallLater is awesome!