Me.Invoke中的“算术运算导致溢出”,带有多线程

时间:2010-03-19 08:11:56

标签: vb.net multithreading overflow

我有这个脚本:

    Private Sub WebDL_AmountDownloadedChanged(ByVal iNewProgress As Long) Handles WebDL.AmountDownloadedChanged
    'On Error Resume Next
    If downloading Then
        Dim wbchanged As New WDL_AmountDownloadedChanged(AddressOf WebDLAmountChanged)
        Me.Invoke(wbchanged, New Object() {CLng(iNewProgress)})
    End If
End Sub

在执行期间,sub接收到iNewProgress这个值:,这会导致溢出:

System.OverflowException未处理   Message =“算术运算导致溢出。”   来源= “System.Windows.Forms的”   堆栈跟踪:        在System.Windows.Forms.Control.MarshaledInvoke(Control caller,Delegate方法,Object [] args,布尔同步)        在System.Windows.Forms.Control.Invoke(Delegate方法,Object [] args)

1 个答案:

答案 0 :(得分:1)

您没有为您发布WebDLAmountChanged方法的代码。但是错误消息说它的参数应该声明为As Long但不是。修正:

Private Sub WebDLAmountChanged(ByVal progress As Long)
  ' etc...
End Sub