Kirk Evans Blog

.NET From a Markup Perspective

Detecting AddHandler in VB.NET

Detecting AddHandler in VB.NET

  • Comments 1
I found this while perusing the newsgroups for awhile...

An event is basically a mask for a delegate - when you declare an event, a hidden delegate type is created that can take methods with the same signature as the event, and a hidden variable of that delegate type is created. So if you know that variable name (hint: event name appended with "Event") you can access the delegate and get a list of the delegates (handlers) that were added to it.

Module Module1
Sub Main()
Dim c As New c1()
End Sub
End Module

Class c1
Event foo()
Sub goo()
AddHandler foo, AddressOf moo
AddHandler foo, AddressOf moo
End Sub
Sub moo()
End Sub
End Class


  • Delegates in VB.NET : Robert McLaws
Page 1 of 1 (1 items)
Leave a Comment
  • Please add 6 and 8 and type the answer here:
  • Post
Translate This Page