We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threads
#15
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.
[-] The following 3 users Like litdev's post:
  • AbsoluteBeginner, jrmrhrb00, z-s
Reply


Messages In This Thread
Threads - by jrmrhrb00 - 11-24-2024, 10:46 PM
RE: Threads - by z-s - 11-25-2024, 04:29 AM
RE: Threads - by jrmrhrb00 - 11-25-2024, 12:12 PM
RE: Threads - by AbsoluteBeginner - 11-25-2024, 01:28 PM
RE: Threads - by z-s - 11-25-2024, 03:31 PM
RE: Threads - by jrmrhrb00 - 11-25-2024, 08:27 PM
RE: Threads - by AbsoluteBeginner - 11-25-2024, 08:51 PM
RE: Threads - by litdev - 11-25-2024, 09:47 PM
RE: Threads - by jrmrhrb00 - 11-25-2024, 11:32 PM
RE: Threads - by z-s - 11-26-2024, 02:59 AM
RE: Threads - by AbsoluteBeginner - 11-26-2024, 09:05 AM
RE: Threads - by jrmrhrb00 - 11-26-2024, 12:56 PM
RE: Threads - by AbsoluteBeginner - 11-26-2024, 03:23 PM
RE: Threads - by jrmrhrb00 - 11-26-2024, 06:41 PM
RE: Threads - by litdev - 11-26-2024, 08:57 PM
RE: Threads - by jrmrhrb00 - 11-29-2024, 02:00 PM
RE: Threads - by z-s - 11-30-2024, 04:29 PM
RE: Threads - by jrmrhrb00 - 12-01-2024, 12:33 PM
RE: Threads - by z-s - 12-02-2024, 05:02 PM
RE: Threads - by jrmrhrb00 - 12-02-2024, 11:22 PM

Forum Jump:


Users browsing this thread: 4 Guest(s)