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