信息技术 ·

在Delphi中使用线程

这是在 Delphi 中轻松使用线程的方法。

synchronize 用得好就行 🙂

函数内容

uses System.Classes, System.SysUtils, Vcl.Forms;

procedure Wait(Proc: TProc);
var
  Thread: TThread;
begin
  Thread := TThread.CreateAnonymousThread(procedure()
  begin
    Proc;
  end);
  Thread.FreeOnTerminate := True;
  Thread.Start;
  while not Thread.Finished do Application.ProcessMessages;
end;

使用方法

Wait(procedure()
begin
  // .... 내용
end);

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注