Application_Launching 事件何时触发?

发布于 2024-09-11 11:41:30 字数 143 浏览 0 评论 0原文

我一直在使用最新的模板(针对 Beta 工具进行了修补)和应用程序生命周期。当我寻找初始化 DispatchHelper 的位置时,我注意到 Application_Launching 事件处理程序是在 MainViewModel 构造函数执行后执行的。这是预期的行为吗?

I have been playing with the latest templates (patched for Beta tools) and application life cycle. When I was looking for a place to initialize the DispatchHelper, I noticed that the Application_Launching event handler was being executed AFTER the MainViewModel constructor has executed. Is this the expected behavior?

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

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

发布评论

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

评论(1

无敌元气妹 2024-09-18 11:41:30

这完全取决于您创建 MainViewModel 的方式和时间。如果您考虑一下,在所有静态对象和主应用程序对象完全构造完成之前,不应执行启动。

许多人希望推迟 MainViewModel 的构建,直到知道是否已启动或重新激活。更好的是推迟视图模型的构建,直到您知道将显示哪个页面。

This entirely depends on how and when you are creating your MainViewModel. If you think about it Launching should not be executed until all static objects and the main application object have been fully constructed.

You many want to delay construction of the MainViewModel until after you know whether you have been launched or re-activated. Even better would be to delay construction of the view model until after you know which page you will be displaying.

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