Asynchronous WEb Services

T

tshad

I have a web service I am calling asynchronously, but I need to make sure I
finish my call.

For example:

****************************************************************
public NewHire()
{
sessionID = "150";
GetInitialNewHireData();
GetNewHire(241);
System.Threading.Thread.Sleep(20000);
}
public void GetInitialNewHireData()
{
System.IAsyncResult asyncResult;

asyncResult = newHireService.BeginreadNewHire(
companyNumber,
"",
session,new AsyncCallback(CallBackInitial), null);
}

public void CallBackInitial(IAsyncResult oRes)
{
nh = newHireService.EndreadNewHire(oRes);
}

private void GetNewHire(int applicantID)
{
Some Code
}
***************************************************************

In the above code, I need to make sure that CallBackInitial finishes before
I exit NewHire.

At the moment, just for testing, I am going to sleep for 20 seconds (which
is not what I want). What I could do is set up a "while loop" that goes to
a sleep for a time (thread.sleep(240)) that is looking at some variable to
see when it changes.

Is there a better way to tell NewHire not to exit until the Call back is
finished?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top