1

I have code typhoon with lazarus installed after a long strugle I have managed to include the unit IdSync to my project.

How can I pass parameteres to a function that I want to execute in the main thread from TIdNotify ?

opc0de
  • 11,557
  • 14
  • 94
  • 187

1 Answers1

1

You have to override the TIdNotify.DoNotify() method, then you can pass whatever parameters you want, eg:

type
  TMyNotify = class(TIdNotify)
  protected
    procedure DoNotify; override;
  end;

procedure TMyNotify.DoNotify;
begin
  SomeFunction(parameters);
end;

.

begin
  ...
  TMyNotify.Create.Notify;
  ...
end;

Presumably, you want the calling thread to specify the parameter values, so just make them members of the class, eg:

type
  TMyNotify = class(TIdNotify)
  protected
    Param1: SomeType;
    Param2: SomeType;
    Param3: SomeType;
    procedure DoNotify; override;
  end;

procedure TMyNotify.DoNotify;
begin
  SomeFunction(Param1, Param2, Param2);
end;

.

begin
  ...
  with TMyNotify.Create do
  begin
    Param1 := ...;
    Param2 := ...;
    Param3 := ...
    Notify;
  end;
  ...
end;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thanks for your support.Any idea why IdSync is not compiling in lazarus by default ? – opc0de Nov 29 '12 at 07:17
  • No, because you did not explain what kind of problem you are having with it. – Remy Lebeau Nov 29 '12 at 18:26
  • http://www.pilotlogic.com/sitejoom/index.php/forum/general-discussions/2346-idsync-not-found#2849 – opc0de Nov 30 '12 at 08:30
  • Either Lazarus is not configured correctly to find the IdSync unit, or the pl_indycomp package was simply compiled without the IdSync unit in it. I'm not a Lazarus user, so I cannot help with that. – Remy Lebeau Nov 30 '12 at 19:52