"Arithmetic operation resulted in overflow" in Me.Invoke with multithreading
I have this script:
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
During execution, the sub receives into iNewProgress this value: , which results in overflow:
System.OverflowException was unhandled Message="Arithmetic operation resulted in an overflow." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) 开发者_StackOverflow中文版at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
You didn't post the code for you WebDLAmountChanged method. But the error message says its argument should have been declare As Long but isn't. Fix:
Private Sub WebDLAmountChanged(ByVal progress As Long)
' etc...
End Sub
精彩评论