Delphi-Quellcode:
procedure TTestLog.AddLog(const AMessage: string);
begin
FListBox.Items.Add(AMessage);
SendMessage(FListBox.Handle, LB_SETTOPINDEX, FListBox.Items.Count-1, 0);
FListBox.Update;
self.Update;
end;
procedure TTestLog.AddLogThreadSafe(const AMessage: string);
begin
if TThread.CurrentThread.ThreadID = MainThreadID then
begin
AddLog(AMessage)
end
else
begin
TThread.Queue(nil,
procedure
begin
AddLog(AMessage);
end);
end;
end;
Probiere mal so und rufe zum Loggen nur AddLogThreadSafe auf.