Am einfachsten geht das mit einem BasisThread:
Delphi-Quellcode:
TMyBaseThread = class( TThread )
public
procedure TuWas1; virtual; abstract;
procedure TuWas2; virtual; abstract;
end;
TThread1 = class( TMyBaseThread )
protected
procedure Execute; override;
public
procedure TuWas1; override;
procedure TuWas2; override;
end;
TThread2 = class( TMyBaseThread )
protected
procedure Execute;
public
procedure TuWas1; override;
procedure TuWas2; override;
end;
und nun
Delphi-Quellcode:
var
MyThread: TMyBaseThread;
first: boolean;
...
if first then MyThread:=TThread1.Create(Self)
else MyThread:=TThread2.Create(Self);
...
MyThread. ...
...
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9
dc 90 9d f0 e9 de 13 da 60)