|
|
|
|
|
ThreadEnd (Function) In french: ThreadFin Stops the execution of the current thread. Remarks - If the current thread is the main thread, both ThreadEnd and EndProgram stop the application.
- To stop a secondary thread:
- First method:
- Call ThreadRequestStop from the thread that should request the stop. The secondary thread will not be stopped automatically.
- The code of the secondary thread must use ThreadStopRequested to check if the stop has been requested. If so, the thread must be properly stopped by terminating the current code or by calling ThreadEnd.
- Second method: Implement a stop system using ThreadEnd. You have the ability to:
- Declare a global variable of type Boolean in the main thread. This variable determines whether the secondary thread must be stopped.
- In the secondary thread, check the value of the variable. If this value is set to True, use ThreadEnd to terminate the current secondary thread.
- In main the thread, set the variable to True to force the secondary thread to stop.
Example:
gbEnd is boolean <critical section>
gbEnd = False
...
ThreadExecute("Thread1", threadNormal, ThreadProcedure)
...
gbEnd = True
...
IF gbEnd = True THEN ThreadEnd()
...
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|