在form1的close或destroy事件中写:
if assigned(mythread) then
begin
mythread.Terminate;
mythread.WaitFor;
end;
出錯:
[Error] Unit1.pas(401): Variable required
[Error] Unit1.pas(403): This form of method call only allowed for class methods
//////////////以下是unit1單元
unit Unit1;
interface
uses
Classes,unit2,ComCtrls,Controls,SysUtils,DateUtils,Forms;
type
mythread = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
public
end;
implementation
procedure mythread.Execute;
begin
/////code
end;
end.
/////////////////////////