开发者

For a Silverlight app, what is the best way to load data from a service at startup?

I am fairly new to Silverlight. I have an application I'm working on that needs some data from the server before the user is can start working with the application. This data is accessible via a WCF service on the web server.

My question is this: what is the best way to go about getting this data at Silverlight applicaiton startup?

My thought it to create a static class with a static member that would hold the results and to make the WCF service call in the 开发者_运维问答Application_Startup event handler. My concern is that if this call is made asynchronously, how can I be certain that the data will have been retrieved from the service prior to the user interacting with the application?

Thanks


The simplest way is to let the application start normally and use a BusyIndicator control to stop the user from interacting with the application.

You could call your service during startup and replace/disable the BusyIndicator control once the wcf call returns.

The following link has some good advices on starting up a Silverlight app: http://blogs.msdn.com/b/slperf/archive/2010/08/13/silverlight-startup-best-practices.aspx


You need to remember that the Application_Startup method is actually loaded when the Silverlight percentage bar comes up, its is not until you get to:

this.RootVisual = new MainPage();

that you are able to put a busy indicator or actually visually show your application. So what i would do is on the Async call back, i would then display:

this.RootVisual = new MainPage();

after you have recieved your data back.

The other comment talks about using a BusyIndicator, but you cant do that in the App.Xaml or App.Xaml.cs file, as at the point of time there is not main page yet.

Thanks

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜