In VB.Net the AddressOf operator can implicitly create the delegate object for you but this is not recommended.
It is possible to declare an event handler without explicitly creating the EventHandler object.
is this anything to do with multi-threaded ?
AddHandler object.Event, AddressOf Method1
AddHandler objButton.Click, AddressOf MyButtonClick
Private Sub Method1
Me.Invoke (New System.Action(AddressOf Method2))
You can actually use the AddressOf operator to assign a subroutine to the delegate variable without creating the delegate object explicitely.
Public Delegate Sub MyDelegate(byVal sArgument As String
Dim onjMyDelegate = AddressOf DebugMsg
Public Delegate Function MyDelegate2(ByVal Name As Object) As String
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext