IMessageBroker
interface and by the default MessageBroker
implementation found in the Radical assembly.The broker itself has a dependency on theIDispatcher
interface, anIDispatcher
can be seen as a wrapper of the currentSynchronizationContext
. We wrap it in aIDispatcher
instance to avoid coupling the broker to a specific implementation.
In the above sample we are using a defaultNullDispatcher
that does nothing and is a good choice for console or web applications where marshaling calls in the main thread is not mandatory. Radical.Windows comes with a built-inWpfDispatcher
.
Broadcast
method, broadcasted messages will be delivered to subscribers asynchronously, and in parallel, thus the subscriber is invoked on a thread that is not the same as the publisher.Dispatch
method that guarantees that all the subscribers are invoked on the same thread of the publisher in a serial manner.InvocationModel
enumeration we can specify that we, as subscribers, need the subscription to be invoked on the main UI thread.