procedure TIdIOHandlerStack.ConnectClient;
procedure DoConnectTimeout(ATimeout: Integer);
var
LSleepTime: Integer;
LThread: TIdConnectThread;
begin
if ATimeout = IdTimeoutDefault
then begin
ATimeout := IdTimeoutInfinite;
end;
LThread := TIdConnectThread.Create(Binding);
try
// IndySleep
if TIdAntiFreezeBase.ShouldUse
then begin
LSleepTime := IndyMin(GAntiFreeze.IdleTimeOut, 125);
end else begin
LSleepTime := 125;
end;
if ATimeout = IdTimeoutInfinite
then begin
while not LThread.Terminated
do begin
IndySleep(LSleepTime);
TIdAntiFreezeBase.DoProcess;
end;
end else
begin
// decrement by the sleep interval. If IndySleep() runs longer then
// requested, that would slow down the loop and exceed the original
// timeout that was requested...
while (ATimeout > 0)
and (
not LThread.Terminated)
do begin
IndySleep(IndyMin(ATimeout, LSleepTime));
TIdAntiFreezeBase.DoProcess;
Dec(ATimeout, IndyMin(ATimeout, LSleepTime));
end;
end;
(...)