开发者

Scope of the Pages in a Silverlight application

I have an app built with the Silverlight Navigation Application Template.

开发者_开发技巧

I have a main form (e.g. MainPage.xaml) and a bunch of Silverlight Pages, which are swapped in and out of the main content area.

In the MainPage.xaml, I have a DispatcherTimer which hits some Uri resources, regardless of which page I am on. Every now and then, it will inexplicably stop firing.

I have an inkling that it has to do with the scope of various pages. Can pages inside the MainPage.xaml take away the scope from its parent?

Or is this something much simpler?


It is much simpler, if you're using the DispatcherTimer, which runs on the Dispatcher thread (xaml), which is the thread used to build the UI, then the Timer wont fire when it is being blocked by another action running on the same thread.

This action could be the previous WebGet call (unlikely since those would be async calls) or more likely what your're doing with the return values might be time consuming, or some pages might require more time than others to build their UI content, hence the Dispatcher event might get queued and fire when the thread is free.

I Suggest you follow the MVVM architectural style of building Silverlight applications, by doing this you can run your timer and WebGet calls from your ViewModel which runs on a different thread, which is unaffected by the UI, hence unaffected by the transition of pages.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜