Services do not run in a different thread. Unless you are using the Threading library, your code always run in the main thread (libraries code can run in other threads though).
See the documentation for StartService:
Basic4android Search: startservice
It says that a Msgbox cannot be shown after this call and before the service has started.
I will explain it. When you call StartService a message is sent to the message queue. Once this message is processed the service starts. If the service is not started after 20 seconds, Android will force close your application. Therefore it is not possible to show a Msgbox at this time. You can change the order of the statements and first show the Msgbox and then call StartService.
I have to say the B4A can handle this, then the code must be amazing.
Because this is pretty much out of order processing. Even though StartService is called, the MsgBox statement may get to the processor before the Service is actually started. How do you actually prevent the Msgbox from being displayed?
Well that is B4A internals, and pretty clever.
..so just to get my head around this...
When we kick off StartService, the main thread doesnt just jump off to the service.
It will keep processing (as long as there is nothing modal) until the end of the sub. (If there are long operations in there that take more than 20 secs we will get ANR).
When the sub has finished, and at some point when the service message reaches the end of the que, the service code is actually started here? Or does it start the the previous sub ends and there is nothing to process for the main thread?
I am just asking because it helps in debugging to know what order instructions are executed in.