C
chris
hello, I can't seem to make this work:
VS2005
I have a simple program that uses a backgroundworker control to execute a
long process (webservice call)
if that webservice call fails, i want to raise an exception and display a
messagebox.
however no matter where i put the Try block to trap the error, it does not
work.
the only example i could find on it is here:
http://msdn2.microsoft.com/en-us/library/4852et58.aspx
in which case they do this:
Private Sub backgroundWorker1_RunWorkerCompleted( _
ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) _
Handles backgroundWorker1.RunWorkerCompleted
' First, handle the case where an exception was thrown.
If Not (e.Error Is Nothing) Then
MessageBox.Show(e.Error.Message)
ElseIf e.Cancelled Then
however, i can't figure out how to set the e.Error in the
RunWorkerCompletedEventArgs.
that same example from the msdn site has the following lines of code in the
procedure that's being called by the backgroundworker:
' The parameter n must be >= 0 and <= 91.
' Fib(n), with n > 91, overflows a long.
If n < 0 OrElse n > 91 Then
Throw New ArgumentException( _
"value must be >= 0 and <= 91", "n")
End If
but this example does not work. the actual numericUpDown control in the
form is set to not allow any values outside those parameters, so the
exception condition ( If n < 0 OrElse n > 91 ) is never true. if you
actually passs something outside of those values to the procedure, you get
the following error when the "Throw New ArgumentException..." line is
executed:
ArgumentException was unhandled by user code.
this is the same problem that i have.
to repeat this, copy the example code from
http://msdn2.microsoft.com/en-us/library/4852et58.aspx
and change the Maximum property on the numericUpDown1 control to something
greater than 91.
run the program, enter the value 92 in the numericUpDown1 control, and click
Start.
the Throw New ArgumentException line generates an error.
does anybody know how to get the e.Error in the RunWorkerCompletedEventArgs
to work?
thanks,
chris.
VS2005
I have a simple program that uses a backgroundworker control to execute a
long process (webservice call)
if that webservice call fails, i want to raise an exception and display a
messagebox.
however no matter where i put the Try block to trap the error, it does not
work.
the only example i could find on it is here:
http://msdn2.microsoft.com/en-us/library/4852et58.aspx
in which case they do this:
Private Sub backgroundWorker1_RunWorkerCompleted( _
ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) _
Handles backgroundWorker1.RunWorkerCompleted
' First, handle the case where an exception was thrown.
If Not (e.Error Is Nothing) Then
MessageBox.Show(e.Error.Message)
ElseIf e.Cancelled Then
however, i can't figure out how to set the e.Error in the
RunWorkerCompletedEventArgs.
that same example from the msdn site has the following lines of code in the
procedure that's being called by the backgroundworker:
' The parameter n must be >= 0 and <= 91.
' Fib(n), with n > 91, overflows a long.
If n < 0 OrElse n > 91 Then
Throw New ArgumentException( _
"value must be >= 0 and <= 91", "n")
End If
but this example does not work. the actual numericUpDown control in the
form is set to not allow any values outside those parameters, so the
exception condition ( If n < 0 OrElse n > 91 ) is never true. if you
actually passs something outside of those values to the procedure, you get
the following error when the "Throw New ArgumentException..." line is
executed:
ArgumentException was unhandled by user code.
this is the same problem that i have.
to repeat this, copy the example code from
http://msdn2.microsoft.com/en-us/library/4852et58.aspx
and change the Maximum property on the numericUpDown1 control to something
greater than 91.
run the program, enter the value 92 in the numericUpDown1 control, and click
Start.
the Throw New ArgumentException line generates an error.
does anybody know how to get the e.Error in the RunWorkerCompletedEventArgs
to work?
thanks,
chris.