ipjyo
asked on
Question regarding asynchronous programming?
I have a function named "Search" which invokes another method "SearchIndividuals" as shown below. In the "SearchIndividuals" it invokes another method "Send" which is defined as asynchronous and as soon as it is done with processing it returns the result using a "callback". In the "SendCallback" method the "Result" variable will be set.
In the "Search" method it needs to process the "Result". How can I make sure it reads the "Result" variable only after it is set in the "SendCallback" method.
Thanks for any help or suggestions.
In the "Search" method it needs to process the "Result". How can I make sure it reads the "Result" variable only after it is set in the "SendCallback" method.
Thanks for any help or suggestions.
//class level variable
private string Result = null;
private void Search(object sender, SearchEventArgs args)
{
SearchIndividuals(Name);
if(Result! = null)
//process result
}
private void SearchIndividuals(string name)
{
AsyncProcess.Send(name);
}
private void SendCallback(object sender, ResponseXml e)
{
Result = e.Response
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.