Reactive Extensions wait for method to finish
We are starting to refactor our silverlight application using some reactive extensions. I have an Initialize method that does some work. I have a call to a method within the Initialize method that must be completed before the rest of the Initialize method is called.
LoadTaskQueues(_currentUser.InstitutionID);
if (_params.Task != null)
{
LoadTaskInformation(_params.Task);
return null;
}
I need to have Loa开发者_如何学CdTaskQueues completed before it runs the LoadTaskInformation.
Assuming that LoadTaskQueues returns IObservable (you don't specify), you want to Subscribe here:
LoadTaskQueues()
.Where(_ => _params.Task != null)
.Subscribe(_ => LoadTaskInformation(_params.Task));
精彩评论