Jump to content
djhfwk

Reduce the wait period of httpcli

Recommended Posts

procedure THttpCli.DoRequestSync(Rq : THttpRequest);  { V7.04 Timeout added }
var
    TimeOutMsec     : UINT;
    bFlag           : Boolean;
    dwWaitMs        : DWORD;	
    AbortRequired   : Boolean;         { V8.71 JK }
    AbortMsg        : String;          { V8.71 JK }
begin
    DoRequestAsync(Rq);
    if not Assigned(FCtrlSocket.Counter) then
        FCtrlSocket.CreateCounter;
    FCtrlSocket.Counter.LastSendTick := IcsGetTickCount64; // Reset counter      { V8.71 }
    if FMultiThreaded then
       dwWaitMs:= 10 else
       dwWaitMs:= 1000;
    TimeOutMsec := FTimeOut * 1000;
    while FState <> httpReady do begin
      {$IFDEF MSWINDOWS}
        if MsgWaitForMultipleObjects(0, Pointer(nil)^, FALSE, dwWaitMs,
                                     QS_ALLINPUT) = WAIT_OBJECT_0 then
      {$ENDIF}
            MessagePump;


      { V8.71 JK see if user wants to abandon this request }

In multithread mode, i think we can use lower period for MsgWaitForMultipleObjects.

 

 

Share this post


Link to post

You can always override the procedure with your own version omitting the MagWait function completely, as some other ICS units do, see TIcsHttpMulti.DoRequestSync in OverbyteIcsHttpMulti.pas,

 

Angus

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×