Indy 9 | Content | Index | Reference

TIdAntiFreezeBase
Hierarchy, Properties, Methods, See Also, Unit: IdAntiFreezeBase
Ancestor for the Indy GUI-integration class.

    TIdAntiFreezeBase = class(TIdBaseComponent)

Unit
IdAntiFreezeBase
Description
Do not create instances of TIdAntiFreezeBase. Applications should create and use instances of the TIdAntiFreeze component.

TIdAntiFreezeBase.Active
TIdAntiFreezeBase
Indicates that the component is active.

    property Active: boolean;

Description
Active is a Boolean property that can be used to enable or disable a TIdAntiFreezeBase component. The default value for Active is ID_Default_TIdAntiFreezeBase_Active as assigned in the Create constructor.

Note: TIdAntiFreezeBase can only perform it's processing when the calling client is the main thread in the application and the component is Active, as indicated in ShouldUse.

TIdAntiFreezeBase.ApplicationHasPriority
TIdAntiFreezeBase, See Also
Specifies that messages from the application main thread have priority.

    property ApplicationHasPriority: Boolean;

Description
ApplicationHasPriority is a Boolean property indicating that an Application should process any Application messages prior to messages from other threads of execution in the TIdAntiFreeze.Process method.

TIdAntiFreezeBase.IdleTimeOut
TIdAntiFreezeBase, See Also
Identifies the idle timeout value in milliseconds.

    property IdleTimeOut: integer;

Description
IdleTimeOut is an Integer property specifies the number of milliseconds that should elapse in calls to Sleep. IdleTimeout is also the timeout value used in TIdSocketHandle.Readable. The default value for IdleTimeout is ID_Default_TIdAntiFreezeBase_IdleTimeOut, as used by both VCL Component streaming and the Create constructor.

TIdAntiFreezeBase.OnlyWhenIdle
TIdAntiFreezeBase, See Also
Specifies the component should yield when the main thread is idle.

    property OnlyWhenIdle: Boolean;

Description
OnlyWhenIdle is a Boolean property that indicates when TIdAntiFreezeBase should yield when the Application main thread is idle. Set OnlyWhenIdle to True to prevent the component from yielding when the application main thread is not idle in DoProcess. Set OnlyWhenIdle to False to allow the component to yield when ShouldUse is True.

The default value for OnlyWhenIdle is ID_Default_TIdAntiFreezeBase_OnlyWhenIdle as assigned using VCL Component streaming and the Create constructor.

TIdAntiFreezeBase.Create
TIdAntiFreezeBase, See Also
Constructs and initializes an instance of TIdAntiFreezeBase.

    constructor Create(AOwner: TComponent); override;

Parameters
AOwner: TComponent
Owner of the object instance.
Description
It is not necessary to explicitly create an instance of the component added in the form designer. These components are created automatically when the application is run, and they are destroyed when the application is closed.

Only one instance of TIdAntiFreezeBase is allowed per application. If another instance already exists, an exception is raised with the RSOnlyOneAntiFreeze message. TIdAntiFreezeBase uses the global variable GAntiFreeze to determine if another instance has already been created.

Create initializes the following properties to their default values:

- Active - ID_Default_TIdAntiFreezeBase_Active

- ApplicationHasPriority - ID_Default_TIdAntiFreezeBase_ApplicationHasPriority

- IdleTimeOut - ID_Default_TIdAntiFreezeBase_OnlyWhenIdle

Note: Do not create instances of TIdAntiFreezeBase. Applications should use the TIdAntiFreeze component.

TIdAntiFreezeBase.Destroy
TIdAntiFreezeBase
Disposes of a TIdAntiFreezeBase object instance.

    destructor Destroy; override;

Description
Destroy sets the unit global variable GAntiFreeze to the value nil, and calls the inherited Destroy method.

It is not recommended to call Destroy directly. Call Free instead. Free checks to ensure that the object reference is not nil before calling Destroy.

TIdAntiFreezeBase.DoProcess
TIdAntiFreezeBase, See Also
Implements basic Process functionality for descendant classes.

    class procedure DoProcess(const AIdle: boolean = true; const AOverride: boolean = false);

Parameters
const AIdle: boolean = true
True forces an Idle state. Default is True.
const AOverride: boolean = false
True overrides the current OnlyWhenIdle property. Default is False.
Description
DoProcess is a class procedure that implements the default behavior for the abstract Process method in TIdAntiFreezeBase descendants. DoProcess allows the component to force an idle state in the main thread of execution, and to allow message processing for other threads of execution.

Set AIdle to True to force an idle state in the main thread regardless of the OnlyWhenIdle value. Set AIdle to False to use the current OnlyWhenIdle value.

Set AOverride to True to force an idle state in the main thread regardless of either AIdle or OnlyWhenIdle values. Set AOverride to False to allow use of the current values in AIdle or OnlyWhenIdle.

DoProcess calls the Process method of the global GAntiFreeze application variable. Note: TIdAntiFreezeBase can only perform DoProcess when the calling client is the main application thread and the component is Active.

TIdAntiFreezeBase.Process
TIdAntiFreezeBase, See Also
Specifies the method that implements the component functionality.

    procedure Process; virtual; abstract;

Description
Process is an abstract virtual procedure in TIdAntiFreezeBase. Descendant classes must implement Process to define the specific functionality performed by the component.

TIdAntiFreezeBase.ShouldUse
TIdAntiFreezeBase, See Also
Indicates that a TIdAntiFreezeBase descendant is in use, and processor cycles should be yielded to the main thread.

    class function ShouldUse: boolean;

Return Value
Boolean - True when the calling client is in the main thread and an active TIdAntiFreezeBase descendant is in use.
Description
ShouldUse is a Boolean class function that indicates when a TIdAntiFreezeBase descendant is in use in an application, and that the component should yield to the main thread of execution. ShouldUse will return True when all of the following conditions are also True:

- GAntiFreeze is not nil.

- InMainThread is True.

- GAntiFreeze is Active.

ShouldUse is called from TIdAntiFreezeBase.Sleep, as well as TIdTCPConnection descendants that implement connection timeout features like TIdTCPClient and TIdTCPServer.

TIdAntiFreezeBase.Sleep
TIdAntiFreezeBase, See Also
Yields processor cycles and optionally processes application messages.

    class procedure Sleep(ATimeout: Integer);

Parameters
ATimeout: Integer
Total milliseconds to yiled to the application.
Description
Sleep is a public class procedure that forces a TIdAntiFreezeBase descendant to yield processor cycles for as many as ATimeout milliseconds. Sleep calls ShouldUse to determine if a TIdAntiFreezeBase descendant is in use in the application. When ShouldUse is True, Sleep calls IdGlobal.Sleep and DoProcess repeatedly until ATimeout milliseconds has elapsed. Each iteration allows IdGlobal.Sleep to pause the application for TIdAntiFreeze.IdleTimeOut milliseconds, and calls DoProcess to allow the main thread of excution to handle application messages.

When ShouldUse is False, Sleep calls IdGlobal.Sleep for ATimeout milliseconds with no additional processing.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.