base.event += this.EventHandler()
is this code safe ? will it cause a leak ?
base.event += this.EventHandler()
is this code safe ? will it cause a leak ?
Yes that is fine, as essentially you are just creating a reference to yourself.
You only need to worry about memory leaks if you create an event from an external object.
It's better practice to override the method that fires the event, for example:
protected override OnClick(object sender,EventArgs e)
{
base.OnClick(sender,e);
// Your code here, or before the base call depending how you want it to operate
}
Of course if it doesn't offer you this method (although it really should) you will have to stick to binding to the Event
itself.