This project has moved and is read-only. For the latest updates, please go here.

MVVMLight Messenger.Unregister - what does it mean 'completely'?

Apr 29, 2014 at 6:18 PM
Edited Apr 30, 2014 at 2:35 PM

I've looked at 'Messenger and references' discussion, but I'm writing a new topic, because my issue is not technical, and I don't want to offtop there. (

I've encountered a doubt - Have I to code cleanup()/RequestCleanup method implementation to unregister previously registered Messenger in my viewmodel class? I'm afraid of memory leaks in the future.
I think I've found the documentation not to be enough bright 4 me.

Description of Messenger.Register<TMessage> is: '... Registering a recipient does not create a hard reference to it, so if this recipient is deleted, no memory leak is caused.'
1) Is this mean that I don't have to take care of it and implement-develop following solutions?

On the other hand, we can find in the code of GalaSoft.MvvmLight.ViewModelBase abstract class the short info about the Cleanup() method:
        // Summary:
        //     Unregisters this instance from the Messenger class.
        //     To cleanup additional resources, override this method, clean up and then
        //     call base.Cleanup().
        public virtual void Cleanup();
so 2) Is only invoking a Cleanup enough to unregister class-instance out of the Messenger?

3) Or maybe I have to invoke 'Messenger.Default.Unregister(this); in the body of a Cleanup method?

4) In the Unregister(Object) doc we read 'Unregisters a messager recipient completely' - what does the 'completely mean'?

I'm very sorry if my post seems to have out of the context quotes, I wanted to point out what I'm more interested in.

Thanks 4 all your posts!