So geht der Q-Trick
Delphi-Quellcode:
Procedure QWas(ADateTime : TDateTime);
var
LDateTime : TDateTime;
begin
LDateTime := ADateTeim;
TThread.Queue(NIL,Procedure
begin
MachWasMit(LDateTime);
end;
end;
...
QWas(DateTime);
...
Verflucht, wie einfach hinterher immer so eine Lösung aussieht! Danke Mav!
So ist das jetzt eine runde Sache.
Delphi-Quellcode:
procedure TMessageThread.SendDateTime(const ADateTime : TDateTime);
var
LDateTime : TDateTime;
begin
LDateTime := ADateTime;
TThread.Queue(nil,
procedure
begin
DoSendMessage(LDateTime);
end);
end;
procedure TMessageThread.DoInternalExecute;
begin
while not Terminated do
begin
try
FLock.Enter;
try
if FStack.Count >= 25 then
begin
if not Terminated then
begin
while FStack.Count <> 0 do
begin
SendDateTime(FStack.Pop);
end;
end;
end;
finally
FLock.Leave;
end;
finally
Sleep(100);
end;
end;
end;
procedure TMessageThread.DoSendMessage(const ADateTime : TDateTime);
var
LMessage : TDateTimeMessage;
begin
LMessage := TDateTimeMessage.Create(ADateTime);
TMessageManager.DefaultManager.SendMessage(Self, LMessage, True);
end;