有两个类,A类,B类 .A 要 B做事, B 跟A说A 你先忙你的 ,我做完告诉你 用c#接口怎么实现? 5
重点在A呼叫B方法BcallAlaterwhenBhasdonesomething....
重点在
A 呼叫 B 方法
B call A later when B has done something. 展开
A 呼叫 B 方法
B call A later when B has done something. 展开
2个回答
展开全部
在B中定义一个委托和一个事件
Public Delegate Sub GenricEventDelegate(Of T, S)(ByVal sender As T, ByVal e As S)
Public Class ItemSynEventArgs
Inherits EventArgs
End Class
然后在A中调用B的事件
B事件写法如下
Protected Overridable Sub OnItemSynSelectAfter(ByVal sender As Object, ByVal e As ItemSynEventArgs)
RaiseEvent ItemSynSelectAfter(Me, e)
End Sub
A中调用B事件写法如下
Protected Sub syninfo_OnItemSynSelectAfter(ByVal sender As Object, ByVal e As ItemSynEventArgs) Handles syninfo.ItemSynSelectAfter
End Sub
Public Delegate Sub GenricEventDelegate(Of T, S)(ByVal sender As T, ByVal e As S)
Public Class ItemSynEventArgs
Inherits EventArgs
End Class
然后在A中调用B的事件
B事件写法如下
Protected Overridable Sub OnItemSynSelectAfter(ByVal sender As Object, ByVal e As ItemSynEventArgs)
RaiseEvent ItemSynSelectAfter(Me, e)
End Sub
A中调用B事件写法如下
Protected Sub syninfo_OnItemSynSelectAfter(ByVal sender As Object, ByVal e As ItemSynEventArgs) Handles syninfo.ItemSynSelectAfter
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询