线程类如下:type
TThreadProc = Procedure of object; TDealThread = class(TThread)
private
FThreadProc : TThreadProc;
FBeforeDestory : TThreadProc;
protected
procedure Execute ;Override;
public
constructor Create(ThreadProc : TThreadProc);OverLoad;
destructor Destroy;Override; property OnBeforeDestory: TThreadProc read FBeforeDestory write FBeforeDestory;
end;implementationuses Forms,windows;constructor TDealThread.Create(ThreadProc : TThreadProc);
begin
FThreadProc:= ThreadProc;
Inherited Create(TRUE);
end;destructor TDealThread.Destroy;
begin
OnBeforeDestory;
Application.MessageBox('文件已经关闭!','提示',mb_OK + MB_ICONERROR);
Inherited Destroy;
end;procedure TDealThread.Execute;
begin
FThreadProc; Terminate;
end;
TThreadProc = Procedure of object; TDealThread = class(TThread)
private
FThreadProc : TThreadProc;
FBeforeDestory : TThreadProc;
protected
procedure Execute ;Override;
public
constructor Create(ThreadProc : TThreadProc);OverLoad;
destructor Destroy;Override; property OnBeforeDestory: TThreadProc read FBeforeDestory write FBeforeDestory;
end;implementationuses Forms,windows;constructor TDealThread.Create(ThreadProc : TThreadProc);
begin
FThreadProc:= ThreadProc;
Inherited Create(TRUE);
end;destructor TDealThread.Destroy;
begin
OnBeforeDestory;
Application.MessageBox('文件已经关闭!','提示',mb_OK + MB_ICONERROR);
Inherited Destroy;
end;procedure TDealThread.Execute;
begin
FThreadProc; Terminate;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货