Hello!
Erel somewhere says that the code into code modules is executed in the main thread of the application.
My question is: where is executed the code of the code modules called from a thread of a multithreaded application? In the main thread or in the thread called it?
The code in code modules will run in the main thread if we call it with CallSubDelayed.
...
4. This is very important point. See the "threads" section in the first post. It is only relevant to server (or WebApps) projects. Each class instance runs in its own thread. If you call ChatShared.NewConnection then this sub will be executed in the class instance thread.
If you call CallSubDelayed then the target thread will be used to execute the code. In the case of code modules it is always the main thread.
Unless it is explicitly written that the event runs on a different thread then the event will run on the main thread. This is the case with ServerSocket, Socket and AsyncStreams events.
They do handle the communication with background threads however the events are delegated to the main thread.