ProLinga-4GL Reference Manual |
---|
THREAD — Start or stop 4GL logic in a thread.
THREAD
START
thread_name
THREAD
STOP
thread_name
The THREAD command is used to either execute logic into a new thread or stop a running thread. ProLinga-4GL is an event driven environment. All responses to events should be quick. For processes that require a long(er) time to execute, they can be started in a separate thread. Similar like a background process, however the logic executed in a thread can contact the main foreground thread to update screen widgets for instance.
At this stage threads can not be nested (yet).
. . . . . . COMMENT *** Start a thread from the main thread (foreground) THREAD START printOrders IF THREADSTATUS <> 0 ERROR "Order print batch could not be started." SEVERITY Error ENDIF . . . . . . THREAD STOP printOrders IF THREADSTATUS <> 0 ERROR "Order print batch could not be stopped or has already finished." SEVERITY Error ENDIF . . . . . .
Logic executed in a thread can check with the built-in function THREADEXIT() if a THREAD STOP command has been issued.
. . . . . . FOREVER IF THREADEXIT() = TRUE() THEN BREAK COMMENT *** Process logic in thread . . . . . . ENDFOR . . . . . .
<< TRANSACTION Command | XML Command >> |