ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
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
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
The Thread type allows you to define all the characteristics of a thread. You can define and change the characteristics of this thread using different WLanguage properties.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
New in version 2025
Android This type of variable is now available for Android applications.
Android Widget This type of variable is now available in Android widget mode.
Java This type of variable is now available for Java applications.
Example
// Declare a variable to handle a thread
t is Thread
// Build a thread and trigger its execution on a procedure
t = ThreadExecute(Proc, ("First parameter", 2))
// Build a thread
t is Thread(Proc, ("First parameter", 2))
// Trigger the execution of the thread
ThreadExecute(t)
Declaration

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>)
where:
  • <Paramètre 1> First parameter of the procedure.
  • ...
  • <Paramètre N> Nth parameter of the procedure.
<Options>: Optional Integer constant
Mode for starting the thread.
threadFullCopyHFSQLContext
(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 are memorized:
  • the directories where the HFSQL Classic data files are located.
  • HFSQL Client/Server connections.
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.
  • thread is automatically secured. In this mode:
    • a compilation error will be displayed if fields are accessed in the thread.
    • 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).
Properties

Properties specific to Thread variables

The following properties can be used to handle Thread variables:
Property nameType usedEffect
New in version 2025
Extra
VariantAllows you to store advanced information without affecting the execution of the application. You can store values of any type (array, etc.). It is also possible to add members to the Extra property.
Example:
MyVariable.Extra.Info1 = Value
MyVariable.Extra[Info2] = Value2
MyVariable.Extra.Date = DateSys()
NameCharacter stringThread name.
This property is read-only.
PriorityInteger constantCurrent priority level of thread:
  • High priority: High priority.
  • Normal priority: Normal priority.
  • Low Priority: Low Priority.
iPhone/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.
Reminder:
  • 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.
New in version 2025
AndroidAndroid Widget Java This property is non-blocking under Android 6. An error appears if the thread has not been completed.
StatusInteger constantThread status:
  • threadStopRequested: Thread stop requested.
  • threadEncours: The thread is currently running..
  • threadNotExecuted: Thread not executed.
  • threadSuspended: The thread is suspended.
  • threadTerminated: The thread exists but is terminated..
This property is read-only.
StopRequestedBoolean
  • True if the thread was requested to stop,
  • False otherwise.
This property is read-only.
Remarks

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…
Comments
Click [Add] to post a comment

Last update: 09/30/2024

Send a report | Local help