方法指針妙用於線程類

unit uThread;

interface

uses
  Classes,SysUtils;

Type
  //Tfun = procedure;
  Tfun = procedure of object;
  TFunThread =Class(TThread)
  private
    fun:Tfun;
  protected
    procedure Execute;override;
  public
    Constructor Create(Afun:Tfun);
    Destructor  Destroy;override;
  end;

implementation

constructor TFunThread.Create(Afun: Tfun);
begin
  inherited Create(true);
  FreeOnTerminate :=true;
  fun:=aFun;
  Resume;
end;

destructor TFunThread.Destroy;
begin
 
end;

procedure TFunThread.Execute;
begin
  fun;
end;

end.

posted @ 2009-03-26 08:37  delphi中间件  阅读(169)  评论(0编辑  收藏  举报