473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Problem with Async WS

Ken
I have an async Web service working inside a Try block just like MS says

Try
Dim cb As New AsyncCallback(AddressOf callbackWs)
myWS.BeginUpdater("StringChain", cb, myWS)
Catch x As Exception
MessageBox.Show("Something happened")
End Try

the Callback routine

Sub callbackWs(ByVal ar As IAsyncResult)
Try
myWS = ar.AsyncState
Dim a As String = myWS.EndUpdater(ar)
MessageBox.Show(a)
Catch x As Exception
MessageBox.Show("Something happened")
End Try
End Sub

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?

ken

Nov 21 '05 #1
2 2446
"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
Nov 21 '05 #2
Ken
thanks..

"Derek Harmon" wrote:
"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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Passynkov, Vadim | last post by:
I am using Asynchronous Query Processing interface from libpq library. And I got some strange results on Solaris My test select query is 'SELECT * from pg_user;' and I use select system...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
8
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page...
2
by: ITALstudio s.r.l. | last post by:
Hy, I make an async call, using delegate and BeginInvoke. When the async call is completed, the callback procedure is executed two times. I debugged the code and I'm sure: I make one async...
0
by: Manfred Braun | last post by:
Hi All, I have a problem reading queue-messages async. My QueueReader has a Start() and a Stop() method and if my app starts, it calls Start(). The problem is, that there are possibly several...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
0
by: micu.radu | last post by:
Hello, Here is my problem, I was trying to generate an html table from an xml file... the easy method is to to use span an data src but this only works in IE so to make it work in mozzila...
3
by: mayur1 | last post by:
Hello everybody, I am trying to connect to DB2 V 8.1 on Red Hat Linux V5 from WebSphere Application Server V6 on Windows Server 2003. The problem that i am facing is that its not able to opent...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.