Skip to content

Instantly share code, notes, and snippets.

@njmube
Created April 22, 2017 19:49
Show Gist options
  • Save njmube/f61621e9a160e423996196217ce53b3b to your computer and use it in GitHub Desktop.
Save njmube/f61621e9a160e423996196217ce53b3b to your computer and use it in GitHub Desktop.
TRESTClient CreateAnonymousThread Delphi
uses IPPeerClient,REST.Client, Data.Bind.Components, Data.Bind.ObjectScope;
procedure TForm1.Button1Click(Sender: TObject);
var
rc: TRESTClient;
rr: TRESTRequest;
res: TRESTResponse;
begin
TThread.CreateAnonymousThread(
procedure
begin
rc := TRESTClient.Create(Self);
rr := TRESTRequest.Create(Self);
res:= TRESTResponse.Create(Self);
try
rr.Client := rc;
rr.Response := res;
rc.BaseURL := 'http://www.mojeld.com';
rr.Execute;
TThread.Synchronize(TThread.CurrentThread,
procedure()
begin
Memo1.Lines.Text := rr.Response.Content;
end
);
finally
res.DisposeOf;
rr.DisposeOf;
rc.DisposeOf;
end;
end
).Start;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment