Thread--------------------------------
unit Unit2;
interface
uses
Classes , IdHTTP;
type
TPrimeThrd = class(TThread)
private
idHTTP1: TidHTTP;
FResultString: string;
protected
procedure UpdateResults;
procedure Execute; override;
public
filename:string;
end;
implementation
uses SysUtils, Dialogs, unit1;
procedure TPrimeThrd.UpdateResults;
begin
Form1.Memo1.Lines.Add(FResultString)
end;
procedure TPrimeThrd.Execute;
begin
idhttp1:=TIdHTTP.Create(nil);
FResultString:=idhttp1.Get(filename);
Synchronize(UpdateResults);
end;
end.
----------------main form----
procedure TForm1.Button5Click(Sender: TObject);
var
newthread1,newthread2:TPrimeThrd;
begin
newthread1:=TPrimeThrd.Create(true);
newthread1.FreeOnTerminate:=true;
newthread1.filename:=listbox1.Items[0];
newthread1.Resume;
end;
end.