Retrieve all delegates registered for one event

  • Thread starter Thread starter Lore Leuneog
  • Start date Start date
L

Lore Leuneog

Hi.

You can add new delegates for an event with += and you can remove delegates
from an event by using: -= but is there a way (method) to list all delegates
added to one event???

Sincerely
Greetings
Lore
 
Hi Lore,

Yes, this is possible.
You can use the GetInvocationList() method in your event,
which returns the list of delegates that have been associated with
the event.

MyDelegate[] delegates = (MyDelegate[])MyEvent.GetInvocationList();

Regards,
Aravind C
 
Hi, Aravind

Thank you very much.
But it seems this doesn't work with build-in Form-Control-Events for example
this.Button.Click-event?
(EventHandler[])this.button.Click.GetInvocationList();
Doesn't work?!

Or did I do it wrong?
Sincerely
Marane



Aravind C said:
Hi Lore,

Yes, this is possible.
You can use the GetInvocationList() method in your event,
which returns the list of delegates that have been associated with
the event.

MyDelegate[] delegates = (MyDelegate[])MyEvent.GetInvocationList();

Regards,
Aravind C


Lore Leuneog said:
Hi.

You can add new delegates for an event with += and you can remove delegates
from an event by using: -= but is there a way (method) to list all delegates
added to one event???

Sincerely
Greetings
Lore
 
Back
Top