C
Chris
Hi,
I add an event-handler to an event-object.
Then prior to raising the event do I want to print info regarding the
event-handlers 'attached' to the event-object :
the Method-information is print OK, but the Target-property is always empty
???
Public Delegate Sub MouseClickedHandler(ByVal obj As Object)
Class Mouse
Public Event MouseClickedEventHandler As MouseClickedHandler
Public Sub MouseClick()
Dim del As [Delegate]
For Each del In GetList()
Console.WriteLine("{0} {1}", del.Method, del.Target)
Next
RaiseEvent MouseClickedEventHandler(Me)
End Sub
Public Function GetList() As System.Delegate()
' Access the underlying delegate-object by 'pasting' the
' word 'event' to the object-name
Return MouseClickedEventHandlerEvent.GetInvocationList
End Function
End Class
Class ConsoleMessage
Public Shared Sub Show(ByVal obj As Object)
Console.WriteLine("ConsoleMessage.Show()")
End Sub
End Class
Class Program
Public Shared Sub Main()
Dim btn1 As New Mouse
Dim consMsg As New ConsoleMessage
AddHandler btn1.MouseClickedEventHandler, AddressOf consMsg.Show
btn1.MouseClick()
End Sub
End Class
Any ideas ?
Thnx
Chris
I add an event-handler to an event-object.
Then prior to raising the event do I want to print info regarding the
event-handlers 'attached' to the event-object :
the Method-information is print OK, but the Target-property is always empty
???
Public Delegate Sub MouseClickedHandler(ByVal obj As Object)
Class Mouse
Public Event MouseClickedEventHandler As MouseClickedHandler
Public Sub MouseClick()
Dim del As [Delegate]
For Each del In GetList()
Console.WriteLine("{0} {1}", del.Method, del.Target)
Next
RaiseEvent MouseClickedEventHandler(Me)
End Sub
Public Function GetList() As System.Delegate()
' Access the underlying delegate-object by 'pasting' the
' word 'event' to the object-name
Return MouseClickedEventHandlerEvent.GetInvocationList
End Function
End Class
Class ConsoleMessage
Public Shared Sub Show(ByVal obj As Object)
Console.WriteLine("ConsoleMessage.Show()")
End Sub
End Class
Class Program
Public Shared Sub Main()
Dim btn1 As New Mouse
Dim consMsg As New ConsoleMessage
AddHandler btn1.MouseClickedEventHandler, AddressOf consMsg.Show
btn1.MouseClick()
End Sub
End Class
Any ideas ?
Thnx
Chris