mythread.pas

来自「服务信息管理系统」· PAS 代码 · 共 67 行

PAS
67
字号
unit mythread;

interface

uses
  Classes, Animate, GIFCtrl, Comctrls, extctrls;

type
  TMYThread = class(TThread)

  private
    { Private declarations }
    TaskGIFAni: TRxGIFAnimator;
    procedure taskstart;
  protected
    procedure Execute; override;
  published
    constructor CreateIt(TaskGIFAnimator: TRxGIFAnimator);
    destructor Destroy; override;
  end;

implementation

uses
  windows, taskjdt;
{ Important: Methods and properties of objects in VCL or CLX can only be used
  in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TMYThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TMYThread }

constructor TMYThread.CreateIt(TaskGIFAnimator: TRxGIFAnimator);
begin
  inherited Create(True);
  FreeOnTerminate := True;
  Synchronize(taskstart);
  Suspended := False;
end;

destructor TMYThread.Destroy;
begin
  //发消息给主窗口,通知本线程完成
  PostMessage(frmtaskjdt.Handle, wm_ThreadDoneMsg, self.ThreadID, 0);
  inherited destroy;
end;

procedure TMYThread.Execute;
begin
  { Place thread code here }
  //Synchronize(taskstart);
end;

procedure TMYThread.taskstart;
begin
  TaskGIFAni.Animate := True;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?