如何在新的 MVVMLight V4 中释放资源
我想知道在 MVVM-Light V4 的新型 ViewModelLocator 中清理资源的最佳方法是什么。据我所知,在版本 3 之前,方法 ViewModelLocator.Cleanup() 调用视图模型的其余 Cleanup() 方法。
在版本 4 中,新的 ViewModel 模板不包含 Cleanup() 方法,也不会在添加到 ViewModelLocator 时生成它们。我在V3相关的其他类似问题中看到,V4是计划集中清洁资源,那么如何实现呢?
谢谢。
艾迪
I would like to know which is the best way to clean up resources in the newly fashioned ViewModelLocator for MVVM-Light V4. As far as I know, until version 3, the method ViewModelLocator.Cleanup() invoked the rest of the viewmodels' Cleanup() methods.
In version 4, with the new ViewModel Templates the Cleanup() methods are not included, nor they are generated when added to the ViewModelLocator. As I read in other similar questions related to V3, V4 was planned to centralize cleaning resources, so how can it be achieved?
Thank you.
Eddie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它们已从模板中消失,但仍然是一个很好的标准实践(它们可能会回来,因为 V4 仍然是测试版)
基本上只需实现您自己的清理方法,并确保在现有/清理的适当时间调用它 -应用程序的顶部。
MVVM 框架本身不会调用清理函数,您必须手动调用它。 (如果我的说法错了,请开枪打我:D)
They are gone from the templates but are still a good standard practice (they may come back yet as V4 is still a beta)
Basically just implement the clean up method your self and ensure that it is called at the appropriate time on existing / clean-up of the app.
The clean-up function isn't called by the MVVM framework itself as it is, you have to call it manually. (shoot me if I'm wrong in that statement there :D)