type
TDBThread = class(TThread)
protected
procedure PrintMsg;
procedure Execute; override;
end;
procedure TDBThread.Execute;
begin
while Not Terminated do
begin
Synchronize(PrintMsg);
Sleep(1500);
end;
end;
procedure TDBThread.PrintMsg;
begin
Form1.Memo1.Lines.Add(TimeToStr(Time) + ': Threading');
end;
procedure TForm1.FormShow(Sender: TObject);
begin
DBThread := TDBThread.Create(False);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DBThread.Terminate;
DBThread.WaitFor;
DBThread.Free;
end;
攪個直執行緒Sleep(1500);就是你要它多久做一次(準一點 )
沒有留言:
張貼留言