Unregister(this) unregisters this instance from everything?

北城余情 提交于 2019-12-11 03:38:15

问题


I am using the mvvm light toolkit for a project and I used to explicitly unregister to all the types of messages each instance was registered to, like this:

Messenger.Default.Unregister<MessageType1>(this);
Messenger.Default.Unregister<MessageType2>(this);
...

But is this

Messenger.Default.Unregister(this);

giving me the same result if I want to unregister to everything ? (for example in the Cleanup method of a ViewModel) I would assume so, but I did not find any hard evidence that my assumption was right.

Thanks!


回答1:


I browsed the source code for a moment, and it does appear that Messenger.Default.Unregister(this) will unregister the target object from any actions it registered previously.



来源:https://stackoverflow.com/questions/7123818/unregisterthis-unregisters-this-instance-from-everything

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!