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
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