Application_Launching 事件何时触发?
我一直在使用最新的模板(针对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这完全取决于您创建 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.