When the AIn
parameter is true, the OnRaw
event handler is being called in the context of a worker thread running inside of TIdIRC
(represented by the AContext
parameter). When AIn
is false, OnRaw
is being called in the context of whatever thread you are sending a command in (and AContext
is nil).
Because OnRaw
is not always run in the context of the main UI thread, you must synchronize with the main UI thread in order to update the Memo safely, eg:
procedure THeaderFooterwithNavigation.IdIRC1Raw(ASender: TIdContext; AIn: Boolean; const AMessage: string);
begin
TThread.Synchronize(nil,
procedure
begin
Memo1.Lines.Add(AMessage);
end
);
end;
However, keep in mind that prior to XE7, TThread.Synchronize()
was broken in FireMonkey, though there is a simple workaround available (mentioned in the above link):
procedure THeaderFooterwithNavigation.Timer1Timer(Sender: TObject);
begin
CheckSynchronize;
end;