Thread in Delphi

Don’t freeze the GUI using a thread.

type
  TMyThread=class(TThread)
  protected
    procedure Execute; override;
  end;

procedure TMyThread.Execute;
var
  ...
begin
  ...
  Form1.Label1.Caption:='Test';
  ...
end;

procedure Form1.Button1Click(Sender: TObject);
begin
  with TMyThread.Create do
    FreeOnTerminate:=True;
end;
Advertisements