TROEventReceiver suggestion and question

Hi guys,

First question, Do we only need one Event Receiver per program? I mean the “ServiceName” property only needs to point to a service on the service library in order to receive all/any event sinks? (just to confirm).

Second, and the suggestion…

We have a method to register event handlers on the EventReceiver that follows the syntax:

procedure RegisterEventHandler(const EventID : string; const EventHandler : TObject);

So e.g. I go and register two different “forms” to receive multiple sinks and implement their respective interfaces on both.

Due to some reason, I need to unregister one of the EventIds from a form, but leave the other ones. There is no method to do that, there is no

procedure UnRegisterEventHandler(const EventID : string; const EventHandler : TObject);

I can only unregister all the existing EventIds, or completly remove the Object from receiving events. I can NOT specifically say I want to stop receiving events on this form for this specific eventID. Just like we did with the registration.

I’m using Delphi Tokyo.

Hi,

yes, you can have only one event receiver in application.

you can unregister specific event or specific object from event receiver.

You are first person why have such problems with event receiver.

Why you can have personal object per event, like

  TestEventObject = class(TComponent, ITest_EventSink)
  public
    procedure Event_String(const NewParam: string);
    procedure Event_Struct(const NewParam: TestStruct);
  end;

?

Hi Evgeny,

Thank you for the response. Probably I’m not explaining myself correctly, what I’m saying is:

If I have a form that implements two event sinks:

TForm1 = class(TForm, ISink1, ISink2)

I can register it as

EventReceiver.RegisterEventHandler(EID_Sink1, Self);

EventReceiver.RegisterEventHandler(EID_Sink2, Self);

Now, what if i want to unregister ONLY EID_Sink2 from Form1, what is the call im supposed to use?

If we have the option to register the objects and sinks individually, shouldnt we have the same functionality to unregister them individually?

As far as I can see we only have:

procedure UnregisterEventHandler(const EventHandler : TObject); overload;
procedure UnregisterEventHandler(const EventIDs : string); overload;

Hope this helps.

Thank you in advance.

this call should work for you:

EventReceiver.UnregisterEventHandler(EID_Sink2);

Hi Evgeny!,

Would that unregister EID_Sink2 from all other forms that may have it implemented or just from Form1?

How the eventreceiver knows what form (object) i want that sink to be unregister?

I could have multiple objects listening to the sink, and I only want to let the eventreceiver know that I dont want it anymore on a specific object (Form1).

Just like it allowed me to register it on different objects if I want it to.

Thank you again.

Thanks, logged as bugs://80349

Thanks, logged as bugs://80350

logged for Delphi and .NET side

bugs://80349 got closed with status fixed.

1 Like

bugs://80350 got closed with status fixed.