Danke. Hab es nun wie folgt programmiert.
Im der Main-
Unit:
Delphi-Quellcode:
interface
type
TMainForm = class(TForm)
private
...
public
...
procedure OnBufferSwitch(bufidx:integer);
end;
implementation
procedure TMainForm.OnBufferSwitch(bufidx:integer);
begin
Label1.Caption := IntToStr(bufidx);
DoSomething(bufidx);
end;
und dann in der Thread-
Unit:
Delphi-Quellcode:
interface
type
TOnBufferSwitch = procedure(bufidx: Integer) of object;
type
TmyThread = class(TThread)
private
...
bufidx: integer;
FOnEvent: TOnBufferSwitch;
protected
procedure Execute; override;
public
property OnEvent: TOnBufferSwitch read FOnEvent write FOnEvent;
end;
implementation
procedure TVASThread.Execute;
var oldbufidx: integer;
begin
FOnEvent := MainForm.OnBufferSwitch; //Zuweisung Ereignisprozedur
while not(Terminated) do
begin
Fillbuffers; //do something
...
if bufidx <> oldbufidx then
Synchronize(SyncBufferSwitch);
sleep(10);
end;
end;
procedure TmyThread.SyncBufferSwitch;
begin
if Assigned(FOnEvent) then
FOnEvent((bufidx);
end;
Scheint zu klappen.
Er wollte so richtig in Delphi einsteigen. Nun steckt er ganz tief drin ...