Coroutines return value

Topics: Actions & Coroutines
Feb 29, 2012 at 9:54 AM


In my WP7 app I am getting the data from two webservices both these service calls are done using coroutines. I have created two classes which implements IResult interface and the entire logic of calling the webservice and getting the data is in these classes. I want to know how can I consolidate the result of these two calls in my viewmodel property. I know there is completed event of IResult interface but it does not have any return value property

Can anyone help ?

Feb 29, 2012 at 11:44 PM

Just create a property with a public getter on your class that implements the IResult interface. Populate this property with the "return" value you want after the operation completes but before the completed event is raised  and just read in that value after you yield it.


Pseudo code:

var webServiceResult = new WebServiceResult();

yield return webServiceResult;

var returnValue = webServiceResult.MyProperty;