Skip to content

Instantly share code, notes, and snippets.

@HEskandari
Created May 26, 2011 06:45
Show Gist options
  • Save HEskandari/992665 to your computer and use it in GitHub Desktop.
Save HEskandari/992665 to your computer and use it in GitHub Desktop.
Abstracted Async model in Silverlight 4.0
public IEnumerable<IResult> LoadLookupCache()
{
yield return ProgressResult.Show("Loading Cache...");
var masterDataService = new MasterDataServiceClient();
var therapyService = new TherapyServiceClient();
masterDataService.getAllHealthFundsCompleted += (o, e) => _serviceHandler.AddTo(e, _lookups.HealthFunds);
masterDataService.getAllPatientCompleted += (o, e) => _serviceHandler.AddTo(e, _lookups.Patients);
therapyService.getTherapyTypesCompleted += (o, e) => _serviceHandler.AddTo(e, _lookups.TherapyTemplateTypes).Apply(x => x.Type = TemplateTypes.Therapy);
yield return new ServiceResult(masterDataService.getAllHealthFundsAsync);
yield return new ServiceResult(masterDataService.getAllPatientAsync);
yield return new ServiceResult(therapyService.getTherapyTypesAsync);
yield return ProgressResult.Hide();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment