Uma forma simples de utilizar threads no Delphi.
Use o synchronize corretamente e tudo correrá bem 🙂
Conteúdo da função
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;
Como utilizar
Wait(procedure()
begin
// .... conteúdo
end);