ViewModel 何时应调用 Services 和isolatedstorage

发布于 2024-10-09 12:50:56 字数 477 浏览 0 评论 0原文

我正在使用 MVVM-Light 工具包并将我的 ViewModelLocator 存储在 App.Resources 中。我注意到我的 ViewModelLocator 类是在 Application_Launching 事件触发之前创建的,并且根据此 来自 Microsoft 的链接,在 Application_Loading 事件触发并加载应用程序之后之前,您不应进行任何网络调用或访问独立存储。

所以我的问题是我的 ViewModelLocator 在其构造函数中创建我的 ViewModel,而 ViewModel 依次进行服务调用并访问isolatedStorage。那么你应该如何正确地做到这一点呢?当没有 Application_Loaded 事件时,如何等待应用程序“加载”?

I'm using the MVVM-Light toolkit and storing my ViewModelLocator in App.Resources. I noticed that my ViewModelLocator class gets created before the Application_Launching event gets fired, and according to this Link from Microsoft you shouldn't make any Network calls or access Isolated Storage until after the Application_Loading event has fired and the application is loaded.

So my problem is that my ViewModelLocator creates my ViewModels in its constructor and the ViewModels in turn are making Service calls and accessing IsolatedStorage. So how are you suppose to do this properly? And how do I wait for the app to be "Loaded" when there is no Application_Loaded event?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

违心° 2024-10-16 12:50:56

我的理解是,如果加载调用是异步的,它就满足您的要求。

否则,您始终可以在加载事件完成后实现自己的标志系统/延迟委托调用。

My understanding is if the load calls are asynchronous, it meets your requirments.

Otherwise, you can always implement your own flag system/ delayed delegate calls after load event completes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文