วิธีใช้เธรดใน 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);