Help / WLanguage / WLanguage functions / Standard functions / Process functions / Threads, semaphores, signals and mutex
  • Declaration
  • Properties specific to Thread variables
  • WLanguage functions that use Thread variables
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
The Thread type allows you to define all the characteristics of a thread. The characteristics of this thread can be defined and changed using different WLanguage properties.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
// Declare a variable to handle a thread
t is Thread
// Build a thread and trigger its execution on a procedure
t = ThreadExécute(Proc, ("First parameter", 2))
// Build a thread
t is Thread(Proc, ("First parameter", 2))
// Trigger the execution of the thread

Declaring a non-described thread Hide the details

MyVariable is Thread
In this case, the thread is not described. The variable will have to be assigned with an existing thread or with the result of one of the thread execution functions.

Describing a thread via the Thread type Hide the details

MyVariable is Thread (<Procedure> [, <Parameters> [, <Options>]])
<Procedure>: Character string or Procedure variable
Procedure to run. This parameter can correspond to:
  • the name of the procedure to run.
  • the name of Procedure variable corresponding to the procedure to run.
<Parameters>: List of values enclosed in brackets and separated by commas
Parameters of procedure to run. This list of parameters has the following format:
(<Parameter 1>, ..., <Parameter N>)
  • <Parameter 1>: First procedure parameter.
  • ...
  • <Parameter N>: Nth procedure parameter.
<Options>: Optional Integer constant
Mode for starting the thread.
(Default value)
Triggers the immediate copy of the current HFSQL context.
Recommended if the thread must take into account the current positions in the files and queries of caller context.
threadGlobalContextForces the use of the global context of the project if the thread is run from a window. The thread will continue to run until the application is closed.
The window context is used by default, therefore the thread is stopped when closing the window.
threadLightCopyHFSQLContextTriggers the immediate copy of a part of the current HFSQL context.
The following elements are stored:
  • the directories where the HFSQL Classic data files are located.
  • HFSQL Client/Server connections.
threadNormalStarts the thread in normal mode. The HFSQL context is copied the first time an HFSQL feature is used.
threadSecureStarts a thread in secure mode. In this mode:
  • a compilation error will occur if the controls are accessed in the thread (or if the procedure uses the "UI" attribute).
  • an exception will be thrown:
    • if the thread accesses the controls at runtime,
    • if the ThreadStop function is called.
  • when the window that triggered the thread is closed, a request to stop the thread is generated (but the thread continues to run after the window is closed).
threadWaitForStartWaits for the actual start of the thread before continuing the execution.
In this case, the thread is described and its description can no longer be modified.
The thread is not executed automatically, so a declaration alone will not start the execution of the thread. You must call one of the thread execution functions to start the thread execution.

Properties specific to Thread variables

The following properties can be used to handle Thread variables:
Property nameType usedEffect
NameCharacter stringThread name.
This property is read-only.
PriorityInteger constantCurrent priority level of thread:
  • PriorityHigh: High priority.
  • PriorityNormal: Standard priority.
  • PriorityLow: Low priority.
Universal Windows 10 AppiPhone/iPadIOS WidgetApple Watch Not available.
ReturnedValueValue returned by the thread. Caution:
  • If the thread is still running, the ReturnedValue property blocks the execution until the thread terminates.
  • If the thread terminates without a fatal error, the property returns the return value(s) of the main procedure of the thread.
This property is read-only.
  • The State property is used to determine the state of the thread.
  • It is possible to wait for the end of a thread with ThreadWait.
StatusInteger constantThread status:
  • threadStopRequested: Thread stop has been requested.
  • threadRunning: The thread is running.
  • threadNotExecuted: The thread has not been executed.
  • threadSuspended: The thread is suspended.
  • threadEnded: The thread exists but it has ended.
This property is read-only.
  • True if the thread was requested to stop,
  • False otherwise.
This property is read-only.

WLanguage functions that use Thread variables

ThreadExecuteStarts the execution of a secondary thread.
ThreadRequestStopSends a stop request to a thread.
ThreadSendSignalThe current thread sends a signal to the specified thread in order to unlock it.
ThreadWaitWaits for the end of the execution of the specified thread.
Minimum version required
  • Version 25
This page is also available for…
Click [Add] to post a comment

Last update: 06/21/2023

Send a report | Local help