0
votes

After join channel application will terminate self after few seconds. Program is run on real telephone LG L65 (no signed), i have one event IdIRC1Raw. Any suggestion?

procedure THeaderFooterwithNavigation.IdIRC1Raw(ASender: TIdContext; AIn: Boolean; const AMessage: string);
begin
  Memo1.Lines.Add(AMessage)
end;
1
My suggestion is to stop using delphi on android platform ... any logs in logcat? Maybe indy component using wrong threads - Selvin
i run this apk on real phone, no loggin - mca64
Does it work correctly in the emulator? - mjn
i dont use emulator (too slow computer) - mca64
The official Android emulator is slow in general. Use another emulator, like BlueStacks or Genymotion. They are much faster. - Remy Lebeau

1 Answers

1
votes

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;