11-26-2024, 08:57 PM
Hi,
All subroutines run on the thread that they were called from, so a call to a subroutine and all child subroutines will be on the same thread as their top level parent.
The main program starts on the UI thread, so all subroutines called from it will also be on the UI thread.
With the exception of specific extension thread control, All EVENT subroutine start on their own (non UI thread), and therefore subroutine calls made from with an EVENT subroutine will also be on the event thread.
1] Yes, the main program is UI thread and all subroutines called from it also are.
2] Exactly the opposite, all event subroutines are NOT on the UI thread, they have their own
3] Yes, as above
4] LDCall can run things async (on a different thread)
One thing to note is that updates to the UI (e.g. moving a shape or anything else) will only take place on the UI thread. If such a UI update is made in an event subroutine, then it wil not actually be done until the event subroutine ends. Also, any variable changes made in event subroutines may conflict with asynchronos UI code (running at the same time, for example the same loop index 'i' may be over-writen by event sub while it is being used in UI thread). These are why I always suggest to do as little work in event sub as possible, just set a flag, and handle it in an 'game loop' on the main UI thread.
All subroutines run on the thread that they were called from, so a call to a subroutine and all child subroutines will be on the same thread as their top level parent.
The main program starts on the UI thread, so all subroutines called from it will also be on the UI thread.
With the exception of specific extension thread control, All EVENT subroutine start on their own (non UI thread), and therefore subroutine calls made from with an EVENT subroutine will also be on the event thread.
1] Yes, the main program is UI thread and all subroutines called from it also are.
2] Exactly the opposite, all event subroutines are NOT on the UI thread, they have their own
3] Yes, as above
4] LDCall can run things async (on a different thread)
One thing to note is that updates to the UI (e.g. moving a shape or anything else) will only take place on the UI thread. If such a UI update is made in an event subroutine, then it wil not actually be done until the event subroutine ends. Also, any variable changes made in event subroutines may conflict with asynchronos UI code (running at the same time, for example the same loop index 'i' may be over-writen by event sub while it is being used in UI thread). These are why I always suggest to do as little work in event sub as possible, just set a flag, and handle it in an 'game loop' on the main UI thread.