I just need a little help to clarify how the Messenger class works with ICleanup in MVVM-Light. I am creating a WPF 4 application in VB.Net with Mvvm-Light v4.
I have a
I've not used the Messenger in MVVM-Light so I do not know if there is an inherent way to cleanup. Here are some general answers to these questions:
You should do your cleanup when you no longer need to know about the message or when no longer need your view model. If the Navigate is not canceled does your ViewModel care about the Navigate message any more (i.e. is it getting unloaded or is the view it supports going away)? If that is the case then you could unregister when you receive the Navigate command and have determined it is OK to navigate.
This I do not know. But on app close it shouldn't matter (for managed objects, see below).
You shouldn't need to worry about these memory leaks with managed objects when the app shuts down, any non-referenced objects will be trashed when the whole app domain is terminated. If you have unmanaged resources being referenced this is another story.