这是在 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);