SyntaxHighlighter

Tuesday, November 3, 2009

VB.NET: Check if an event handler has been assigned to a method

This is how one checks if an event handler (or any delegate handler for that matter) has been assigned to a method.

' Create the delegate
Public Delegate Sub UpdateEvent()
' Create a handler
Public Update As UpdateEvent

' ...
' Rest of the class
' ...

' Check if the event handler has been assigned to
If Not Update Is Nothing Then
Update()
End If