how to execute multiple posts requests at the same time, this code sample is only represent a single anonymous thread, total are 15, however, even with one thread the post response becomes slower by time, at first it starts fast, then it slows down until it nearly stops!, i couldn't figure out whats wrong, this my 9th attempt to solve this. I tried net client, TTask, but they has bugs, any ideas? i mean codes, Thanks.
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;