0

如何同时执行多个post请求,这个代码示例只代表一个匿名线程,总共15个,但是,即使是一个线程,post响应也会随着时间的推移而变慢,开始很快,然后变慢直到它几乎停止!,我不知道出了什么问题,这是我第 9 次尝试解决这个问题。我试过网络客户端,TTask,但他们有错误,有什么想法吗?我的意思是代码,谢谢。

procedure TForm1.Test99;
var
 lHTTP: TIdHTTP;
 Params,Reply: TStringList;
begin
  lHTTP := TIdHTTP.Create(nil);
  Params := TStringList.Create;
  Reply  := TStringList.Create;

 TThread.CreateAnonymousThread(procedure ()
 var
  i : integer;
 begin
   for i := 0 to Z.Count-1 do
 begin
   Params.Add('Id=' +Z.Strings[i]);
   try
     Reply.Text := lHTTP.Post('https://www.mxhs95.com/test', Params);
     if AnsiContainsStr(Reply.Text, 'id')
     then
     begin
      TThread.Synchronize (TThread.CurrentThread,
      procedure ()
              begin
                Memo1.Lines.Add( Z.Strings[i]);
                Label2.Caption := Memo1.Lines.Count.ToString;
              end);             
     end;  
 end;
 Finally

  end;

end;
end).Start;
end;
4

0 回答 0