Forget it. If you use the Begin* functions (for some reason they were
commented out in the example code below) rather then the delegates then
everything works fine.
To: [EMAIL PROTECTED]
cc:
Matt Horne <[EMAIL PROTECTED]> Subject: [DOTNET] Exception in async web
service...callback never
Sent by: The DOTNET list will be called?
retired 7/1/02
<[EMAIL PROTECTED]>
06/05/2002 03:57 PM
Please respond to The DOTNET
list will be retired 7/1/02
I found that if a web service that is called async throws an error, the
client async callback never gets called. Is there something that I am
missing?
Server code...
<WebMethod()> Public Function DoSomeWork(ByVal Delay As Integer) As Integer
Throw New Exception("I am broken")
End Function
Client code...
Public Delegate Function myAsyncDelegate(ByVal intReturn As Integer) As
Integer
Private Sub cmdWebServAsync_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cmdWebServAsync.Click
'Create instance of web service proxy
'Call the method "DoSomeWork" asyncronously. The first parameter
is the value
'for the actual method call parameter and the second parameter is
the address of the
'function to be called when the method completes execution.
'WebServ.BeginDoSomeWork(Int32.Parse(txtDelay.Text), New
AsyncCallback(AddressOf Me.MyCallBack), Nothing)
'Create instance of web service proxy
Dim WebServ As New localhost.Service1()
Dim AsyncCallback As New AsyncCallback(AddressOf Me.MyCallBack)
Dim AsyncDelegate As New myAsyncDelegate(AddressOf
WebServ.DoSomeWork)
Dim AsyncResult As IAsyncResult
'Call the web service asynchronously and display the results in a
message box.
AsyncResult = AsyncDelegate.BeginInvoke(Int32.Parse(txtDelay.Text),
AsyncCallback, Nothing)
MessageBox.Show("Async call started", "Asynchronous Call")
End Sub
Private Shared Sub MyCallBack(ByVal ar As System.IAsyncResult)
' I never get called when an exception is thrown on the server...
Dim AsyncDelegate As myAsyncDelegate
Dim AsyncResult As AsyncResult
Dim ReturnValue As Integer
AsyncResult = CType(ar, AsyncResult)
AsyncDelegate = AsyncResult.AsyncDelegate()
'End async call
ReturnValue = AsyncDelegate.EndInvoke(AsyncResult)
MessageBox.Show("Asynchronous response has returned with the value:
" & ReturnValue.ToString)
End Sub
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.