End Module
Public Class class1
Public Delegate Sub test(ByVal m As Integer)
Public Event testhandler As test
Public Sub a(ByVal ta As test)
ta.Invoke(3)
End Sub
Public Sub c_testhandler(ByVal e As Integer)
Console.Write(e)
Console.ReadLine()
End Sub
'<STAThread()> _
Shared Sub Main()
Dim class1 As New class1
AddHandler class1.testhandler, AddressOf class1.c_testhandler
class1.a(AddressOf class1.c_testhandler)
End Sub
最简单来说,我想把AddHandler这个操作封装以下,通过这个函数可以将一个Event和一个Delegate连接在一起。
public sub myaddhandler(myevent as ******, mydetegate as dategate)
addhandler myevent, mydelegate
end sub