Wie jede Componente etc. muss der Thread mit Methoden... erst definiert werden:
Delphi-Quellcode:
type
TMyThread = class(TThread)
protected
procedure execute; override;
private
{ Private declarations }
public
{ Public declarations }
end;
Delphi-Quellcode:
procedure TMyThread.execute;
begin
inherited execute;
//auszuführender Thread Code
end;
Aufruf/Erstellen des Threads Variante1:
Delphi-Quellcode:
[...]
var mythread: TMyThread;
begin
mythread := TMyThread.Create(False); { sofort starten (nix mehr ändern) }
end;
Aufruf/Erstellen des Threads Variante2:
Delphi-Quellcode:
[...]
var mythread: TMyThread;
begin
mythread := TMyThread.Create(True); { create suspended – mythread does not run yet }
mythread.Priority := tpLowest; { set the priority to lowest than normal }
mythread.Resume; { now run the thread }
end;