"Ken" <Ke*@discussions.microsoft.com> wrote in message news:EE**********************************@microsof t.com...
I have an async Web service working inside a Try block just like MS says
: : If for any reason is impossible to reach the WS the program does not enter
into the Catch block. It does nothing so how can I alert the user that is not
connection to the WS?
You need to set a time out beyond which you aren't going to wait any longer
and assume the worst. Don't lose the handle to the IAsyncResult that Begin-
Updater( ) returned to you,
Dim updaterResult As IAsyncResult
' . . .
updaterResult = myWS.BeginUpdater( "StringChain", cb, myWS)
Now, if you're willing to sit around and wait, or spawn another worker
thread to wait for you ;-) then you can use the WaitHandle of the IAsyncResult
and give it a time out period that you're willing to wait for the web service to
return,
' Wait up to 15 seconds for Updater web service to complete,
' if it's not done by then WaitOne returns False and I terminate
' the request.
'
If Not updaterResult.AsyncWaitHandle.WaitOne( 15000, True) Then
myWS.Abort
End If
If the Updater web service hasn't completed within fifteen seconds then the worker
thread is aborted (note that you'll then get called on your callback, if any, for a
SOAP fault indicating the connection was closed [by you]).
This sort of gets away from why you wanted an asynchronous call in the first
place, unless you put this into a second "watchdog" thread whose only purpose
is to wait for the web service response, and end matters if they take too long.
The other thing to do is to wire yourself to a Timer and have the Timer call you
back in 15 seconds (or whatever period of latency you're willing to tolerate) so
you can check the AsyncWaitHandle to see if the work has finished.
In either case these timeout techniques involve three threads (the main thread,
the web request worker thread, and a watchdog worker thread to timeout).
Derek Harmon