Delphi-Quellcode:
type
TAProcedure = procedure(i: integer);
TMyThread = class(TThread)
private
FAProcedure: TAProcedure;
protected
constructor Create(CreateSuspended: boolean; AProcedure: TAProcedure);
procedure Execute; override;
end;
{...}
implementation
procedure MyProcedure(i: integer); // Kopf entspricht TAProcedure
begin
{..}
end;
{ TMyThread }
constructor TMyThread.Create(CreateSuspended: boolean;
AProcedure: TAProcedure);
begin
inherited Create(CreateSuspended);
FAProcedure := AProcedure;
end;
procedure TMyThread.Execute;
begin
if Assigned(FAProcedure) then
FAProcedure(1);
end;
{ TfrmMain }
procedure TfrmMain.BtnClick(Sender: TObject);
begin
TMyThread.Create(false, @MyProcedure); // passende Prozedur übergeben
end;
Beachte aber, dass du eventuelle Zugriffe auf die
VCL synchronisieren musst.