Kilho.net
IT

Using Threads in Delphi

Here’s an easy way to use threads in Delphi.

Just use synchronize properly 🙂

Function

[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]

How to Use

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

Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *