将事件和处理程序作为参数传递

时间:2014-03-19 15:03:59

标签: vb.net events

在VB.NET中你有声明:

AddHandler object As Event, object As Delegate

我需要能够在运行时激活和停用处理程序,所以我想要类似于此的东西:

Class EventHandler
    Private mEvent as Event
    Private mDelegate As Delegate
    Public Sub New(evt As Event, del as Delegate)
        mEvent=evt
        mDeletate=del
    End Sub
    Public Sub Activate
        AddHandler mEvent, Delegate
    End Sub
    Public Sub Deactivate
        RemoveHandler mEvent, Delegate
    End Sub
End Class

这可能吗?

0 个答案:

没有答案
相关问题