Kilho.net
信息技术

在Delphi中使用线程

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

synchronize 用得好就行 🙂

函数内容

[code lang=”delphi”]
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;
[/code]

使用方法

[code lang=”delphi”]
Wait(procedure()
begin
// …. 내용
end);
[/code]

发表回复

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