Möglich wäre auch die Verwendung von TThread.Queue(nil...)
Delphi-Quellcode:
procedure TSourceThread.DoSendData;
begin
FOwner.lbl_CountSource.Caption := IntToStr(FCounter);
if Assigned(FSendData) then
FSendData(FCounter);
end;
procedure TSourceThread.Execute;
begin
inherited;
while not Terminated do
begin
if (WaitForSingleObject(FEvent, INFINITE) = WAIT_OBJECT_0) and not Terminated then
begin
TThread.Queue(nil, DoSendData);
Sleep(50 + Random(200));
Inc(FCounter);
end;
end;
end;