- Special case: Stopping a thread that contains the SocketWairForConnexion function
In french: ThreadArrête
This function is not recommended because it violently stops the current thread. It may cause serious issues (incomplete file writing, loss of memory, critical section not deleted, etc.). It is recommended to use ThreadRequestStop
Stops a secondary thread.
Reminder: A thread is a process run in parallel with the current application (main thread). This allows you to run a task in the background (e.g. backup, etc.).
<Result> = ThreadStop(<Thread name> [, <Maximum timeout>])
- True if the thread was stopped or if the thread does not exist,
- False if the thread is locked
<Thread name>: Character string
Name of the thread to be stopped. This name is given when running the thread (ThreadExecute).
- If this parameter corresponds to an empty string (""), the current thread is stopped. If the current thread is the main thread, ThreadStop is equivalent to EndProgram.
Only this behavior is allowed. ThreadStop can only be used on the current thread.
- If the name of the thread does not exist, ThreadStop has no effect and it returns True.
- If the name of the thread is a child thread or a sibling thread, ThreadStop waits for the current WLanguage function (HReadFirst for example) to end. In this case, ThreadStop is a blocking function.
- If this parameter corresponds to the threadMain constant, the main thread is stopped.
- Otherwise, a WLanguage error occurs.
<Maximum timeout>: Optional integer
Maximum timeout in hundredths of a second.
This parameter can correspond to:
- If the thread is not stopped at the end of specified duration, <Result> is set to False.
- If this parameter is not specified or if it corresponds to the Infinite constant, the wait is infinite.
- an integer corresponding to the number of hundredths of a second,
- a Duration variable,
- the duration in a readable format (e.g., 1 s or 10 ms).
Special case: Stopping a thread that contains the SocketWairForConnexion function
Timeout = 30
This page is also available for…