Is it necessary to set to Nothing
(in Dispose()) all WithEvents
fields?
Apparently Handles
keyword adds handlers to such fields, but does not remove it until this field is not Nothing
, and this can generate memory leaks?!.
This should be specially actual on cases like
class Foo
{
Private WithEvents _bar as Bar
Public Sub New(ByVal bar as Bar)
_bar = bar
End Sub
Private Sub Bar_Changed(ByVal sender as Object, _
ByVal e as EventArgs) Handles _bar.Changed
'... '
End Sub
}