Home > Mobile >  Freezing Indy HTTP. Get on Android Delphi 11 inside thread
Freezing Indy HTTP. Get on Android Delphi 11 inside thread

Time:12-20

I recently migrate from Delph 10.2 to Delphi 11. Base of this code I get http from server periodically inside thread.

  myth := TThread.CreateAnonymousThread(
  procedure
    var IdHTTP1:TIdHTTP;
  begin

        ...
        ...
        IdHTTP1:=TIdHTTP.Create();
        IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) 
          Gecko/20100101Firefox/12.0';
        ...
        ...
        IdHTTP1.Get(Url,ResStm);
        ...
        ...

 end);
 myth.start

This code run on Delphi 10.2 without any freezing, but on a Delphi 11 freeze this line 'IdHTTP1.Get(Url,ResStm);' over 5 seconds.

CodePudding user response:

Uses of bad place for sync procedure for update content of form was reason of this freezing.

TThread.Synchronize (TThread.CurrentThread,procedure ()
  begin
    ....
    ...
    ...
  end);

By limit this enclose structure to some of necessary lines, freezing limited to milliseconds and that is not noticeable. for example: I placed decompressing of stream outside of sync.

Finally mention that: this freezing occurs on Delphi 11

  • Related