Prism CompositeEvent does not start with anonymous filter delegate specified by helper class

I have a TestEvent class as follows:

class TestEvent: CompositePresentationEvent<object>
    {
        public void Subscribe(Action<object> action, int number)
        {
            this.Subscribe(action, ThreadOption.PublisherThread, false, arg=>arg.Equals(number));
        }
    }

If I signed up for the event as follows:

eventAggregator.GetEvent<TestEvent>().Subscribe(_=>MessageBox.Show("Hi"), 3);

The event does not fire. However, if I signed it like this:

eventAggregator.GetEvent<TestEvent>().Subscribe(_ => MessageBox.Show("Hi"), ThreadOption.PublisherThread, false, arg => arg.Equals(3));

This is fire. Although conceptually, syntactically and logically, both are similar. The only difference is that the former uses a helper method in the event class to subscribe to the event.

, , CompositeEvent, , keepSubscriberAlive = true ( ) . , , ? , ? , false, / ?

- ?

+3
1

, TestEvent. , . , TestEvent Subscribe.

, , Subscribe, . .

+3

Source: https://habr.com/ru/post/1788816/


All Articles