日期:2014-05-18  浏览次数:20752 次

Invoke过程为什么到了Sub End会重复调用?在线等~
两个文件,GetMarketPricesTask.vb和frmMain.vb
GetMarketPricesTask中有:
VB.NET code
        Public Delegate Sub OnGetMarketPricesDelegate(ByVal respUK As betfair.UK.exchange.GetMarketPricesResp, ByVal respAU As betfair.AU.exchange.GetMarketPricesResp, _
                                                      ByVal respBetUK As betfair.UK.exchange.GetCurrentBetsResp, ByVal respBetAU As betfair.AU.exchange.GetCurrentBetsResp)
        Public Shared Event OnGetMarketPrices As OnGetMarketPricesDelegate

然后是下面是一个Sub xxx

frmMain中:
VB.NET code

   AddHandler GetMarketPricesTask.OnGetMarketPrices, AddressOf GetMarketPricesTask_OnGetGetMarketPrices

 Private Sub GetMarketPricesTask_OnGetGetMarketPrices()
       If InvokeRequired Then
            Invoke(New Tasks.GetMarketPricesTask.OnGetMarketPricesDelegate(AddressOf GetMarketPricesTask_OnGetGetMarketPrices), New Object() {respUK, respAU, respBetUK, respBetAU})
        Else
'Do Something
End If




问题就是 GetMarketPricesTask_OnGetGetMarketPrices()这个过程总会重复调用,快崩溃了,每当调用一次,就多执行一次,如按钮第3次触发这个事件GetMarketPricesTask_OnGetGetMarketPrices()这个过程就会重复执行3次,里面的内容都会被执行3次,为什么啊,怎么都搞不明白,求救!~!!!!

------解决方案--------------------
你是不是在按钮的Click中执行的添加事件???