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]

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です