TIdThreadComponent
Implements a visual component using a thread of execution.
Unit
Description
TIdThreadComponent is a
TIdCustomThreadComponent descendant that exposes properties and event handlers from the ancestor class that reference the protected thread for the component. Read and write access for properties that reference the protected thread are delegated to the internal
TIdThread instance.
Event handlers published in TIdThreadComponent are provided to the internal thread instance to allow event notifications and synchronization during thread execution.
Indicates the internal thread is running and has not been Stopped.
Description
Active is a Boolean property that is published in
TIdThreadComponent, and indicates when the internal thread for the component is running and has not been Stopped. Changing the value in Active will result in a call to the Start method for the internal thread when Active is True. A call to the Stop method for the internal thread is made when Active is False. The read value for Active is True when the internal thread is not Stopped.
Note: At design-time, the value for Active does not examine the state of the internal thread since it is not started or stopped in the IDE.
Event handler signalled when the internal thread has completed.
Parameters
Sender
Threaded component for the event notification.
Description
OnAfterExecute is a published
TIdNotifyThreadComponentEvent property in IdThreadComponent that represents the event handler used to signal completion of the internal thread. OnAfterExecute is triggered using the component context in Sender when the internal thread performs its AfterExecute method.
Applications must assigned a procedure to the event handler to allow responding to the event notification.
Indicates that thread execution has been Stopped, but may be Resumed.
Parameters
Sender
Threaded component for the event notification.
Description
OnAfterRun is a published
TIdNotifyThreadComponentEvent property in IdThreadComponent that represents the event handler used to signal that execution of the internal thread has been stopped, but the thread is still running. OnAfterRun is triggered using the component context in Sender when the internal thread performs its AfterRun method. OnAfterRun occurs prior to CleanUp and AfterExecute for the internal thread.
Applications must assigned a procedure to the event handler to allow responding to the event notification.
Indicates the thread is about to enter the inner control loop.
property OnBeforeExecute;
Parameters
Sender
Threaded component for the event notification.
Description
OnBeforeExecute is a published
TIdNotifyThreadComponentEvent property in
TIdThreadComponent that represents the event handler used to signal that the internal thread is about to begin running in the inner control loop. OnBeforeExecute is triggered using the component context in Sender when the internal thread performs its BeforeExecute method. OnBeforeExecute occurs prior to the TIdThread.BeforeRun method and both the
OnBeforeRun and
OnRun event handlers.
Applications must assigned a procedure to the event handler to allow responding to the event notification.
Use OnAfterExecute to perform application specific processing required when the thread has been completed in it's entirety.
Indicates the thread is about an iteration in the inner control loop.
Parameters
Sender
Threaded component for the event notification.
Description
OnBeforeRun is a published
TIdNotifyThreadComponentEvent property in
TIdThreadComponent that represents the event handler used to signal that the thread is about to perform an iteration in the inner control loop. OnBeforeRun is triggered using the component context in Sender when the internal thread performs its BeforeRun method. OnBeforeRun occurs prior to the TIdThread.Run method and the
OnRun event handler.
Applications must assigned a procedure to the event handler to allow responding to the event notification.
Use OnAfterRun to perform application specific processing required when the thread has completed an iteration in the inner control loop.
Event handler for thread teardown after execution.
Parameters
Sender
Threaded component for the event notification.
Description
OnCleanup is a published
TIdNotifyThreadComponentEvent property in
TIdThreadComponent that represents the event handler signalled after the internal thread instance for the component performs it CleanUp method. OnCleanup is executed just prior to the TIdThread.AfterExecute method and the
OnAfterExecute event handler.
OnCleanup is triggered by the internal thread instance using the component context in Sender.
Event handler for an exception raised during internal thread execution.
Parameters
AException
Exception raised during execution of the internal thread.
Sender
Threaded component for the exception handler.
Description
OnException is a published
TIdExceptionThreadComponentEvent property that represents the event handler signalled when an exception occurs during execution of the internal thread for the component. OnException is triggerd from
TIdThread.OnException using the component context in Sender. AException is the exception raised from the control loop in TIdThread.Execute.
Event handler signalled when the internal thread is Run.
Parameters
Sender
Threaded component for the event notification.
Description
OnRun is a published
TIdNotifyThreadComponentEvent property in
TIdThreadComponent that represents the event handler signalled when the internal thread is Run. OnRun is triggered from the TIdThread.Run method using the component context in Sender.
Event handler triggered when the internal thread is stopped.
Description
OnStopped is a published
TIdNotifyThreadComponentEvent property in
TIdThreadComponent that represents the event handler signalled when execution of the internal thread for the component has been stopped.
OnStopped is triggered after entering the control loop in TIdThread.Execute, and when TIdThread.Stopped contains the value True. If the internal thread has also been Terminated, the control loop is exited and the thread calls AfterExecute.
Event handler triggered when the internal thread is Terminated.
Description
Indicates the relative scheduling priority for the internal thread.
Description
Priority is a published
TIdThreadPriority property in
TIdThreadComponent that indicates the relative scheduling priority of the internal thread instance for the component. Read and write access to value in Priority is delegated to the internal thread instance.
Priority can be changed request or release CPU cycles during thread execution. Warning: Boosting the thread priority of a CPU intensive operation may “starve” the other threads in the application. Only apply priority boosts to threads that spend most of their time waiting for external events.
Indicates the action to be taken when the internal thread is Stopped.
Description
StopMode is a published
TIdThreadStopMode property in
TIdThreadComponent that indicates the action when the internal thread contains True in the Stopped property. StopMode is updated when the internal thread calls its Stop method.
Read and write access to the value in StopMode is delegated to the internal thread instance for the component.