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

Strange bug in WakactionGeneric

Sep 27, 2012 at 4:06 PM



I've been looking at using the framwork and have been trying out your clean shutdown example, I modified the shutdown service (to make it more readable to me).

        public static void RequestShutdown()

            NotificationMessageAction act = new NotificationMessageAction(
                                       (param) => ShouldAbortShutdown(param));
            IMessenger messenger = Messenger.Default;

            if (!_shouldAbortShutdown)
                // This time it is for real
                Messenger.Default.Send(new NotificationMessage(Notifications.NotifyShutdown));


        static public void ShouldAbortShutdown(bool abort)
            _shouldAbortShutdown = abort;
I then started to get an exception (Non-static method requires a target.) in the Execute(T parameter) in the weakactoinGeneric class where the ActionTarget is null in the method.execute(...)

Now I think I have resolved this by modifying the execute to be as follows:


public void Execute(T parameter)
            if (_staticAction != null)
            var actionTarget = ActionTarget;

            if (IsAlive)
                if (Method != null
                    && ActionReference != null
                    && actionTarget != null)
                        new object[]

This appears to solve the problem and is similar to what happens in the weakaction class. Not being an expert I'm gussing that the re-referenceing the actionTarget makes it a strong reference again? Please could you also explain why the use of weak references here as I don't see the need? Thanks