[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Classes' (#rtl)

# TThread.WaitFor

Waits for the thread to terminate and returns the exit status.

## Declaration

Source position: classesh.inc line 1825

`public function TThread.WaitFor: Integer;`

## Description

WaitFor waits for the thread to terminate, and returns the exit status. Note that when executed in the main thread, this method calls CheckSynchronize, this is done to avoid deadlocks: if the thread is waiting for a synchronize, then the synchronize methods will be executed and then the WaitFor will return.

## See also

TThread.Terminated |  | Indicates whether the Terminatemethod was called by the user.
TThread.WaitFor |  | Waits for the thread to terminate and returns the exit status.
TThread.FreeOnTerminate |  | Indicates whether the thread should free itself when it stops executing.
TThread.Synchronize |  | Synchronizes the thread by executing the method in the main thread.