【问题标题】:"Arithmetic operation resulted in overflow" in Me.Invoke with multithreadingMe.Invoke 中的“算术运算导致溢出”多线程
【发布时间】:2011-01-29 08:49:38
【问题描述】:

我有这个脚本:

    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="算术运算导致溢出。" 源="系统.Windows.Forms" 堆栈跟踪: 在 System.Windows.Forms.Control.MarshaledInvoke(控制调用者,委托方法,对象 [] 参数,布尔同步) 在 System.Windows.Forms.Control.Invoke(委托方法,Object[] args)

【问题讨论】:

    标签: vb.net multithreading overflow


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2011-05-15
      • 2011-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多