"Multibinding" for Cross Module Comms

Topics: Prism v1
May 22, 2009 at 7:39 PM

Hi All,

I've got a problem that I can't think of a satisfactory solution to at the moment.  I'm looking for some advice.

The problem is actually relatively simple.  One of the modules I'm dealing with is tiny, all it provides in the UI is a single combobox but the functionality it provides is pretty all encompassing, I'm wondering if anyone has faced this and has a solution.

The combobox allows the user to effectively switch the context of the whole application.  It publishes one event and subscribes to one event.  The published event tells the rest of the subscribed modules to switch context to a certain state.  The switching
for some modules initiate calls to serialised data on the local machine and for other modules it initiates calls to various WCF services.  At that same moment it publishes this event it also goes into a disabled state preventing any more switching.  The event it subscribes too is published by a module once it has completed its work and has switched context.

The problem is that I don't just want it to go back into an enabled state until *all* the subscribers have successfully completed switching.  Effectively the responses will come back in totally random order over various periods of time.

I can think of a solution but it doesn't seem particularly robust frankly.  I was thinking that when a module subscribes to the "switch context" event it could also register itself with the combobox module, then the combobox could evaluate a list of these subscribes to check for responses, once all responses are in and successful it would then re-enable.  Almost a bit like XAML multibinding but for cross-module comms.

This almost feels like a mini framework within CAL, maybe I'm also missing something in my knowledge of the EventAggregator.

Any ideas would be great.

May 22, 2009 at 9:50 PM



A possible approach could be adding a property to your event to access the amount of subscribers it has. For example:

public class SwitchContextEvent : CompositeWpfEvent<FundOrder>


        public int SubscriptionsCount { get { return this.Subscriptions.Count; } }



Since you know how many subscribers there are when you publish the event you can wait until you get the same amount of responses to enable the ComboBox again.


Please let me know if this helps.


Damian Schenkelman


May 22, 2009 at 10:14 PM

That sounds like an awesome solution.  I'm going to have a play with that.


Thank You!