Link to home
Start Free TrialLog in
Avatar of ipjyo
ipjyoFlag for United States of America

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

}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial