views:

96

answers:

1

What's better:

Private Sub Window_Closed(sender As Object, e As EventArgs) Handles Me.Closed
    'Do stuff
End Sub

Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
    MyBase.OnClosed(e)
    'Do stuff
End Sub

I personally think that the second is better, 1st because it doesn't add a handler, and also because the syntax is more simple. Especially in C#, where adding handlers is more robust, and there is no 'handles' keyword.

A: 

I would favour the event handler, because of maintainability:

  • You can't forget to call the base class method MyBase.OnClosed().
  • You can easily add multiple handlers.

It does not matter one bit, performance-wise. (I only add this because you tagged the question with performance-comparison... but really, this will only matter if you close forms millions of times a second.)

Thomas
Even for each his own taste and I think I will keep using the overriding, I marked your post as answer in honor of the helpful info you provided.
Shimmy