Internet Direct (Indy) Version 9.0.1 Beta
TIdThread
Ancestor for all Indy threads.

TIdThread = class(TThread)
Description
TIdThread is a descendant of the Delphi TThread, and the ancestor of thread classes used in Indy. Create a descendant of TIdThread to represent a thread of execution in a multi-threaded application.

TIdThread extends the functionality of TThread to include flexible methods for control of thread state and notification of changes to thread state.

TIdThread implements the inherited abstract Execute method to provide a known thread execution mechanism. Execute can detect thread termination, suspend and resume threads, and provide exception handling for an exception raised during thread execution. Execute also provides finer control of thread execution by extending TThread to include the equivalent of thread event handlers.

TIdThread and descendants should override the abstract Run method, and implement the virtual methods BeforeRun and AfterRun.

The Execute method iterates through a loop, making calls to BeforeRun, Run, and AfterRun to provide thread functionality. This loop can be stopped by calling the Stop method. Use the Start method to begin or resume execution of the loop.

TIdThread descendants can be used in conjunction with a TIdThreadMgr descendants to address the overhead issues associated with thread creation and resource allocation in a multi-threaded application.

Note: Do not use properties and methods of other objects directly in the Run method of a thread. Use the Synchronize method to call a procedure that can access objects and resources which are not thread-safe.