Classes

Method Thread():start() Foundation

Executes program code in a thread.

Syntax
:start( [<cFuncName>|<bCodeBlock>], ;
        [<xParamList,...>]          ) --> lSuccess
Parameters
<cFuncName>
<cFuncName> is a character string containing the name of the function or procedure to be executed in the thread. The identifier must be known (visible at runtime), which means the name of a STATIC FUNCTION or STATIC PROCEDURE cannot be specified.
<bCodeBlock>
Alternatively, a code block can be specified as the first parameter instead of a function name. <bCodeBlock> is evaluated in the thread.
<xParamList>
<xParamList> is a comma-separated list of expressions that is passed to the specified function or code block. Variables in <xParamList> are always passed by value and not by reference to the new thread. The reference operator is ignored when :start() is called.
Return

If the thread is started, the method :start() returns the value .T. (true), otherwise it returns .F. (false).

Description

The method :start() starts the thread which is managed by the Thread object and executes the function <cFuncName> or evaluates the code block <bCodeBlock>. The parameters <xParamList> are passed on to the function or code block, respectively. At the beginning and at the end of the method, functions or code blocks are executed if they are specified in the instance variables :atStart and :atEnd. As long as program code is running in the thread, the instance variable :activecontains the value .T. (true). As soon as the program code has ended, :active contains .F. (false) and the return value of <cFuncName>or <bCodeBlock> is assigned to the instance variable :result.

Repeated calls to :start() are rejected as long as the thread is active. The method can only be called again when the instance variable :active contains the value .F. (false).

When a start time is defined with :setStartTime(), the Thread object delays program execution in the thread until this time is reached. Also, if a time interval for repeated execution is specified with :setInterval(), the program code is restarted automatically in the thread.

When the parameter <cFuncName> is not specified, the method :start() passes all parameters from <xParamList> to the method :execute(). This method can only be called by subclasses of the Thread class. This allows the Thread class to be modified to fit user-specific needs.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.