Post method with idhttp without locking

Asked

Viewed 1,641 times

1

Hello, I will explain more or less what I wish to do, I have some data that need to be sent by post method to a server, but whenever it makes a upload the program "Freeza"(program crashes quickly), i have several data daily that need to be sent and in case I would like to use the code in a timer, and whenever the server response reaches it jump to the next line.

var
S: TStringList;
M: TStream;
pega : string;
begin
 S := TStringList.Create;
 M := TMemoryStream.Create;

 pega := Listaimportados.Items[i];
 Inc(i);
 nome.text := Copy(pega, 0, 16);
 sobrenome.text := Copy(pega, 18, 2);
 valor.text := Copy(pega, 23, 2);
 try
   S.Values['processamento'] := 'normal';
   S.Values['nome'] := nome.text;
   S.Values['sobrenome'] := sobrenome.text;
   S.Values['valor'] := valor.text;

   IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
   IdHTTP1.Post('http://localhost/envia.php', S, M);
   Memo1.Lines.Add(Format('Resposta: %s', [IdHTTP1.ResponseText]));

   M.Position := 0;
   S.LoadFromStream(M);
   Memo1.Lines.AddStrings(S);
 finally
   S.Free;
   M.Free;
 end;
end;

I need enough that the program does not lock and that whenever the answer arrives it should jump to the next line(maybe Inc(i);), I will do this check how? on another timer?.

1 answer

3


Put the Tidantifreeze component of the Indy palette into the form that will no longer freeze.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.