使用 Prism 为 SL4 OOB 应用程序定制启动页/起始页
我可以使用一些帮助来找出为使用 Prism 2 构建并在浏览器外运行的 Silverlight 4 客户端应用程序实现“启动”/启动页面的最佳方法。
我正在支持一套应用程序,并正在开发所有应用程序都可以使用的通用控件和服务库。作为其中的一部分,我将创建 UnityBootstrapper 类的子类来注册服务。
我遇到过这样的情况:我需要在启动时使用来自服务器的数据“预加载”一些服务。这可能需要一些时间,因此我们希望在执行所有启动步骤时显示启动屏幕。由于我们的浏览器已经用完了,我知道这并不简单。任何帮助表示赞赏。
我也愿意接受其他无法“延迟加载”的启动数据方法。
I could use some help figuring out the best way to implement a "splash"/start-up page for my Silverlight 4 client applications that are built using Prism 2 and run out-of-browser.
I am supporting a suite of applications and am working on a common library of controls and services that all of the applications may use. As part of this, I am creating a subclass of the UnityBootstrapper class to register the services.
I've run into a situation where I need to 'pre-load' a couple of the services with data from the server on start-up. This could take a bit of time so we'd like to display a splash screen while all of the start-up steps are executed. Since we are running out-of-browser, I know this isn't straight forward. Any help is appreciated.
I'm also open to other approaches for start-up data that can't be 'lazy loaded'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查 prism 的示例项目(在您的 PRISM 安装下):
这将向您展示如何知道模块何时加载/完成
您可以在 Shell 上使用带有样式的忙碌指示器来指示您正在加载。
Check prism's sample project(under your PRISM installation):
That will show you how to KNOW when module loads/completed
You can just use Busy indicator with style over your Shell to indicate that you loading.
因此,经过多次尝试和错误,我提出了以下方法,我现在正在研究它的效果如何。
我在类库中创建了一个 Shell UserControl,充当 UI 的包装器(容器)。我将此控件设置为 RootVisual。在此控件的内容中,我添加了启动控件/视图并进行所有必要的启动服务调用。使用 WaitHandles,我会等到所有调用都返回,然后再用应用程序的起始页替换启动控件。
该应用程序不知道其中的任何一个是如何工作的,这是我的目标。它们只是重写我添加到引导程序中的方法来进行任何启动服务调用。服务调用在后台线程上执行,代码使用 WaitHandle.WaitAll 进行阻塞,直到所有调用完成,然后使用 Dispatcher.BeginInvoke 将启动画面替换为应用程序的主页。
这一切似乎运作得很好。
So after many trials and errors, I've come up with the following approach that I am now working through to see how well it works.
I've created a Shell UserControl in my class library that acts as a wrapper (container) for the UI. I set this control as the RootVisual. Within the content of this control, I add my splash control/view and make all of the necessary startup service calls. Using WaitHandles, I wait until all of the calls have returned before replacing the splash control with the application's start page.
The application has no idea how any of this works, which was my goal. They simply override a method I've added to the bootstrapper to make any startup service calls. The service calls are executed on a background thread and the code uses WaitHandle.WaitAll to block until all of the calls are completed which then uses Dispatcher.BeginInvoke to replace the splash with the application's main page.
This all seems to work pretty well.