How to determine if event has been delegated?

  • Thread starter Thread starter Vince
  • Start date Start date
V

Vince

I'm writing a framework component, and I would like to be able to
determine if a particular event has been delegated or not.
By event delegation, I mean:
control.event += handler (method);

I want to know if the event has already been delegated or not. Even
though events use the "+=" syntax, they're not true indexers, so they
don't have a Count.

Any ideas?
TIA,
Vince
 
How about something like "control.event == null" when no delegates have been
bound. This is what the OnXXX methods do to determine if they should raise
the event.
 
Vince.... event.GetInvocationList() may work.

Delegate[] handlers= callhome.GetInvocationList();
foreach (Delegate d in handlers)
{
d.DynamicInvoke(new object[]{this,
    new
ThreadedProcessEventArgs(this.ConsoleOutput,this.ConsoleError,this.ExitC
od
e)});
}

Regards,
Jeff
I want to know if the event has already been delegated or not
 
Back
Top