implementation
uses Unit1;
{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure MyThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ MyThread }
procedure MyThread.AddLineToMemo;
begin
form1.memo1.lines.add('=============');
end;
procedure MyThread.Execute;
var
i :integer;
begin
{ Place thread code here }
for i := 1 to 100 do
Synchronize(AddLineToMemo);
end;
end.
在单击事件中有。
var
mythread1:MyThread;
begin
mythread1.create(true);
mythread1.FreeOnTerminate:=true;
mythread1.resume;
end;