Skip to content

Instantly share code, notes, and snippets.

@mharju
Created October 14, 2011 08:16
Show Gist options
  • Save mharju/1286545 to your computer and use it in GitHub Desktop.
Save mharju/1286545 to your computer and use it in GitHub Desktop.
Asynchronous loading of a resource with resource names coming from external resource
protected void LoadFeedByName(string name, OpenReadCompletedEventHandler handler)
{
WebClient client = new WebClient();
client.OpenReadCompleted += handler;
if (App.UriProvider.IsFeedsAvailable)
{
client.OpenReadAsync(App.UriProvider.UriForName(name));
}
else
{
App.UriProvider.FeedUrisAvailable +=
new FeedUriAvalableEventHandler(
(object sender, EventArgs args) =>
{
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
client.OpenReadAsync(App.UriProvider.UriForName(name));
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment