THREAD Command

THREAD — Start or stop 4GL logic in a thread.

Synopsis

THREAD START thread_name

THREAD STOP thread_name

Introduction

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).

Arguments

thread_name

Any data reference as well as hard coded string holding the name of a thread.

Example

. . .
. . .
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
. . .
. . .

Related Commands

None.