K
koenemy
Unregistered / Unconfirmed
GUEST, unregistred user!
线程Execute函数的值,怎么用自定义的事件返回
unit ExecuteHandler;
interface
uses
Classes, SearchBase;
type
TExecuteHandler = class(TThread)
private
TS: TSearchBase;
FOnGetPlace: TNotifyEvent;//这块定义一个事件,,有问题嘛
protected
procedure Execute;
override;
public
constructor Create(CreateSuspended: Boolean;
TS: TSearchBase);
published
property OnGetPlace: TNotifyEvnet read FOnGetPlace write FOnGetPlace;//这块总提示找不着TNotifyEvnet
end;
implementation
{ TExecuteHandler }
constructor TExecuteHandler.Create(CreateSuspended: Boolean;
TS: TSearchBase);
begin
FreeOnTerminate := True;
Self.TS := TS;
inherited Create(CreateSuspended);
end;
procedure TExecuteHandler.Execute;
var
place: string;
begin
place := self.TS.GetPlace;
if self.Terminated then
begin
if Assigned(OnGetPlace) then
OnGetPlace(place);//在这触发这事件,参数place对不
exit;
end;
end;
end.
unit ExecuteHandler;
interface
uses
Classes, SearchBase;
type
TExecuteHandler = class(TThread)
private
TS: TSearchBase;
FOnGetPlace: TNotifyEvent;//这块定义一个事件,,有问题嘛
protected
procedure Execute;
override;
public
constructor Create(CreateSuspended: Boolean;
TS: TSearchBase);
published
property OnGetPlace: TNotifyEvnet read FOnGetPlace write FOnGetPlace;//这块总提示找不着TNotifyEvnet
end;
implementation
{ TExecuteHandler }
constructor TExecuteHandler.Create(CreateSuspended: Boolean;
TS: TSearchBase);
begin
FreeOnTerminate := True;
Self.TS := TS;
inherited Create(CreateSuspended);
end;
procedure TExecuteHandler.Execute;
var
place: string;
begin
place := self.TS.GetPlace;
if self.Terminated then
begin
if Assigned(OnGetPlace) then
OnGetPlace(place);//在这触发这事件,参数place对不
exit;
end;
end;
end.