Delphi 多线程使用

1. 定义线程类
type
  TMyThread = class(TThread)
  private
    { Private declarations }  
      fPos:Integer;  // 变量
  protected

    procedure GetMailList;
    procedure UpdatepBar;   // 同步到主线程

    procedure Execute; override;

  end;

2. 编写线程需要做的事
         procedure TMyThread.Execute;
begin
  { Place thread code here }

  FreeOnTerminate:= True;   // 执行完自动释放线程

  self.GetMailList;  // 处理事件
  
end;
----------------------------
procedure TMyThread.GetMailList;
begin
     //  编写事件
        fPos := 50;
    // 调用同步
    Synchronize(UpdatepBar);   /
    Sleep(50);
end;
-----------------------
procedure TMyThread.UpdatepBar;
begin
  aEMailHint.pbar.Position := fPos;
end;
原文地址:https://www.cnblogs.com/windson/p/12569178.html