开发者

run WebClient.DownloadStringCompleted before loading MainPage_Loaded in silverlight [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I开发者_如何学运维 want to load this event handler before MainPage_Loaded

WebClient wc = new WebClient(); 

wc.DownloadStringCompleted += new 
DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

wc.DownloadStringAsync(new Uri("./ImageList.xml", UriKind.Relative));

void wc_DownloadStringCompleted(object sender, 
    System.Net.DownloadStringCompletedEventArgs e){.....}


I think this was the question
I want to "load some resources" "Asynchronously" before loading the MainPage!

WebClient wc = new WebClient(); 

wc.DownloadStringCompleted += 
            new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

wc.DownloadStringAsync(new Uri("./ImageList.xml", UriKind.Relative));

void wc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e){.....}

Answer

If it is the main page of your application so you can add this code to "app.xaml.cs" in Application_Startup event handler. note that since you are loading the resource asynchronously then you should load the main page in your event handler not Application_Startup unless you don’t care if the Main page got loaded before completion of the resource loading process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜