Created
October 14, 2011 08:16
-
-
Save mharju/1286545 to your computer and use it in GitHub Desktop.
Asynchronous loading of a resource with resource names coming from external resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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