473,799 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asyncronous call to web service

Joe
Hello All:

I have an executable that makes several asynchronous calls to a web service.
The executable increments a counter for each async Web service call and
decrements the counter whenever the call returns. When the counter == 0
(i.e. all calls have returned), I do some clean up and close down the
executable.

What if all of the calls don't return? What can I do if five async calls
are made and four come back. My current app would just sit around, waiting
for the fifth call to come back. Let's say that the network connection is
down; my app willl remain open and I don't want this. I'm not a big fan of
timers; they remind me of my VB 6 days.

Is there a more elegant way to handle this?

TIA,
--
Joe
Jul 19 '06 #1
2 1994
Joe,
you would want to use some version of the WaitHandle, for example (untested):

void EnterBtn_Click( Object Src, EventArgs E)
{
MyMath.Math math = new MyMath.Math();
// Call to Add Web service method asynchronously
// and then wait for it to complete.
IAsyncResult result =
math.BeginAdd(C onvert.ToInt32( Num1.Text),
Convert.ToInt32 (Num2.Text),
null,
null);
// Wait for asynchronous call to complete or timeout
result.AsyncWai tHandle.WaitOne (timeout , true|false);
// Complete the asynchronous call to Add Web service method.
float total = math.EndAdd(res ult);
// Display results in a Label control.
Total.Text = "Total: " + total.ToString( );
}
There are a number of overloads to the WaitOne method, you could even have
an array of WaitHandles.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Joe" wrote:
Hello All:

I have an executable that makes several asynchronous calls to a web service.
The executable increments a counter for each async Web service call and
decrements the counter whenever the call returns. When the counter == 0
(i.e. all calls have returned), I do some clean up and close down the
executable.

What if all of the calls don't return? What can I do if five async calls
are made and four come back. My current app would just sit around, waiting
for the fifth call to come back. Let's say that the network connection is
down; my app willl remain open and I don't want this. I'm not a big fan of
timers; they remind me of my VB 6 days.

Is there a more elegant way to handle this?

TIA,
--
Joe
Jul 19 '06 #2
Joe
Thanks.
--
Joe
"Peter Bromberg [C# MVP]" wrote:
Joe,
you would want to use some version of the WaitHandle, for example (untested):

void EnterBtn_Click( Object Src, EventArgs E)
{
MyMath.Math math = new MyMath.Math();
// Call to Add Web service method asynchronously
// and then wait for it to complete.
IAsyncResult result =
math.BeginAdd(C onvert.ToInt32( Num1.Text),
Convert.ToInt32 (Num2.Text),
null,
null);
// Wait for asynchronous call to complete or timeout
result.AsyncWai tHandle.WaitOne (timeout , true|false);
// Complete the asynchronous call to Add Web service method.
float total = math.EndAdd(res ult);
// Display results in a Label control.
Total.Text = "Total: " + total.ToString( );
}
There are a number of overloads to the WaitOne method, you could even have
an array of WaitHandles.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Joe" wrote:
Hello All:

I have an executable that makes several asynchronous calls to a web service.
The executable increments a counter for each async Web service call and
decrements the counter whenever the call returns. When the counter == 0
(i.e. all calls have returned), I do some clean up and close down the
executable.

What if all of the calls don't return? What can I do if five async calls
are made and four come back. My current app would just sit around, waiting
for the fifth call to come back. Let's say that the network connection is
down; my app willl remain open and I don't want this. I'm not a big fan of
timers; they remind me of my VB 6 days.

Is there a more elegant way to handle this?

TIA,
--
Joe
Jul 20 '06 #3

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

Similar topics

0
1341
by: Ivar | last post by:
Hi, Is SocketOptionName.ReciveTimeout usable with asyncronous socket methods ? With Recive method it works but BeginRecive can't get it working.
0
1103
by: Andrés Joaquín | last post by:
Hello, I have a problem with a TCP Asyncronous Server Implementation. I take the solution from the Microsoft Site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht ml/cpconnon-blockingserversocketexample.asp) and implemented it but when i test it I get problems... I used the below test client code to test the Syncronous Server but after a
1
1220
by: Nathan | last post by:
On my .NET web project I am trying to make an asyncronous call to a function using IAsyncResult. The function will process for about a 1/2 hour. before it completes, the process abruptly ends as though it has timed out. I'm not sure what is timing out. Would it be the page I am making the async call from? Or possibly the connection/command objects I am using to connect to my sql db?
1
3032
by: alex002 | last post by:
Dear all, I am writing to a C# program to connect to the telnet server and getting data; however, I know that I can use either TCPClient and Asyncronous Socket to do the program. However, I don't know which is better and why. Can any one tell me about this? Thank you for all of your help. Alex
0
1024
by: Paul Fi | last post by:
what is the point of asyncronously processing requests or responses at channel sinks when we can do asyncronous calls at the .net remoting application level ? do we consider AsyncProcessResponse method of the IClientChannelSink class as a callback function? how is async calls differ from having threads controling my calls?
1
4468
by: il RicercatoreSbadato | last post by:
title: asyncronous Socket and EndAccept() question: hi to all, I am working with a server that uses the sockets in a asyncronous way. When I want to STOP the server I do the following: - serverMainSocket.EndAccept(); - serverMainSocket.Shutdown(SocketShutdown.Both); - serverMainSocket.Close(); My problem is on the first instruction. I don't know what can I put as argument in the EndAccept().
1
2191
by: Allan Ebdrup | last post by:
I'm inside a function where I have a static cache, when the cache needs to be updated I want to do it asyncronously, because updating the cache takes a while. I want to use thread safety when writing and reading the cache (a Mutex?) Private Function Count(ByVal Guid)As Int32 Static Dim countResults As Hashtable = New Hashtable Static Dim countResultTimestamps As Hashtable = New Hashtable 'Here I want to call...
3
1733
by: OJ | last post by:
Hi, I have written a small C# 2.0 DLL which acts as a client to a Socket based server over the internet. I have written both synchronous and asynchronous methods to connect, send, and receive data from the server. Each request/response can take upto 180 seconds. I am trying to use the asyncronous calls in an ASP.NET C# 2.0 Webcontrol, which displays the returned data. At the moment I am happily using the asyncronous functions and events...
1
1471
by: -pb- | last post by:
Hi, Is it possible to develop a web service which can send asyncronous notification to the client application using Web Service and not the Remoting? What I really want to know that, if each client application have a web service which gets the notification from server web service (on some task running on server). Is this possible? Does anyone have done it before.
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.