PC Review


Reply
Thread Tools Rate Thread

Asyncronous call to web service

 
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      19th Jul 2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      19th Jul 2006
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(Convert.ToInt32(Num1.Text),
Convert.ToInt32(Num2.Text),
null,
null);
// Wait for asynchronous call to complete or timeout
result.AsyncWaitHandle.WaitOne(timeout , true|false);
// Complete the asynchronous call to Add Web service method.
float total = math.EndAdd(result);
// 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

 
Reply With Quote
 
=?Utf-8?B?Sm9l?=
Guest
Posts: n/a
 
      20th Jul 2006
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(Convert.ToInt32(Num1.Text),
> Convert.ToInt32(Num2.Text),
> null,
> null);
> // Wait for asynchronous call to complete or timeout
> result.AsyncWaitHandle.WaitOne(timeout , true|false);
> // Complete the asynchronous call to Add Web service method.
> float total = math.EndAdd(result);
> // 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to call .net web service call from java client? B Deepak Microsoft C# .NET 2 21st Sep 2005 05:30 AM
asyncronous call times out before finishing =?Utf-8?B?TmF0aGFu?= Microsoft Dot NET 1 2nd Jul 2005 12:29 AM
asyncronous method call Allan Ebdrup Microsoft C# .NET 1 13th May 2005 03:21 PM
Service Control Manager The Remote Procedure Call (RPC) service terminated unexp Arlan R Spratte Windows XP Help 1 12th Dec 2003 04:34 AM
REMOTE CALL PROCEDURE call (RPC) SERVICE Pete Q Windows XP Networking 2 23rd Nov 2003 03:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:40 PM.