Wednesday, 23 September 2009

The Other Event Handler

Normally when I declare an Event I do it like this. The Easy way.

public event EventHandler Closing;

But you can have more power if you do it like this.

private EventHandler canClose;
public event EventHandler Closing
{
add { this.canClose += value; }
remove { this.canClose -= value; }
}

You can find out who is registering against your event.
Very handy..