Finding out number of subscribers to an event

G

Guest

Hello,

Is it possible to find out how many methods are listening to a certain
event? For example, if a number of methods subscribed to a controls DragDrop
event using +=, can I find out how many methods in total are listening to the
DragDrop event of the control?

If I can't find out the exact number of methods listening to the DragDrop
event, can I somehow remove all listeners of that event at once? I tried
using m_Control.DragDrop = null, but the compiler says I'm only allowed to
use DragDrop with += or -=.

I read about GetInvocationList() but I only found examples of its usage on
custom delegates. Im not sure if/how it is applicable to a controls DragDrop
event.

Thanks for your help,
-Flack
 
J

Jon Skeet [C# MVP]

Flack said:
Is it possible to find out how many methods are listening to a certain
event?

No - at least, not portably. One of the main points of an event as
opposed to a delegate is that you only have access to
subscribe/unsubscribe, not to the underlying delegate itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top