I am calling a method by using delegates and the target function calls a callback once it is complete. However I do want to wait till its callback is called so that I can get the data.
For example:
//setup
public IAsyncResult BeginGetTies(Request request, AsyncCallback cb, object asyncState)
{
_service.GetTiesCompleted += Callback;
_gets = new getTimeSeriesData(GetTies);
IAsyncResult r = _gets.BeginInvoke(request, cb, asyncState);
return r;
}
private void GetTies(Request request)
{
_service.GetTies(tsr, id);
}
private void Callback(object sender, event e)
{
// this gets called after EndGet
}
Now this _service.GetTies
uses a callback with events. However I get the control back when _service.GetTies
calls gets completed. After that the callback is invoked. I want to wait till the callback gets invoked so that I can use the results.
Please help.