PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Declaration
  • Properties specific to the description of Thread variables
  • WLanguage functions that manipulate Thread variables
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
The Thread type allows you to define all the characteristics of a thread. The characteristics of this thread can be defined and modified using different WLanguage properties.
Remark: See Declaring a variable for more details on the declaration of this type of variable and the use of WLanguage properties.
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 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:
  • <Parameter 1>: First procedure parameter.
  • ...
  • <Parameter N>: Nth procedure parameter.
<Options>: Optional Integer constant
Mode for starting the thread.
threadWaitForStartWaits for the actual start of the thread before continuing the execution.
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.
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.
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.
Versions 26 and later
threadSecure
New in version 26
threadSecure
threadSecure
Starts 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 ThreadStop is used.
  • 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).
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.
Remarks

Properties specific to the description of Thread variables

The following properties can be used to handle a Thread variable:
Property nameType usedEffect
StopRequestedBoolean
  • True if the thread was requested to stop,
  • False otherwise.
This property is read-only.
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.
NameCharacter stringThread name.
This property is read-only.
PriorityInteger constantCurrent priority level of thread:
  • PriorityHigh: High priority.
  • PriorityNormal: Standard priority.
  • PriorityLow: Low priority.
Versions 26 and later
ReturnedValue
New in version 26
ReturnedValue
ReturnedValue
Value 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.

WLanguage functions that manipulate Thread variables

Versions 09 and later
ThreadExecute
New in version 09
ThreadExecute
ThreadExecute
Starts the execution of a secondary thread.
Versions 25 and later
ThreadRequestStop
New in version 25
ThreadRequestStop
ThreadRequestStop
Sends a stop request to a thread.
Versions 09 and later
ThreadSendSignal
New in version 09
ThreadSendSignal
ThreadSendSignal
The current thread sends a signal to the specified thread in order to unlock it.
Versions 09 and later
ThreadWait
New in version 09
ThreadWait
ThreadWait
Waits for the end of execution of specified thread.
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment