Terminates the specified thread.
[ bTerminated = ] TerminateThread ( hThread )
The TerminateThread procedure syntax has the following parts:
Name |
Type |
Description |
bTerminated |
Bool |
A boolean expression specifying whether the thread was terminated. |
hThread |
Val AHandle |
Handle to the thread. |
bTerminated can have one of the following values:
Value |
Description |
True * |
The thread was terminated. |
False |
The thread was not terminated. |
TerminateThread will end the specified thread flushing call stack and deleting local procedure variables and deleting the thread handle. If the specified is the main application thread, all the other threads will be terminated abnormally before exiting the current thread. You can call TerminateThread for ATEasy created threads that were created using CreateThread, or threads that were created by the application libraries. It is recommended to call TerminateThread (to avoid abnormal thread termination) only in cases were the thread cannot end normally using ExitThread or returning from the thread procedure. Abnormal thread termination, may cause variables or internal state of ATEasy run-time to be in unpredictable manner and it is recommended to exit the process after calling this procedure.
The following example will terminate a thread of handle hThread1:
TerminateThread(hThread1)
CreateThread, ExitThread, SuspendThread, WaitForSingleObject, Exit