コード例 #1
0
        private static void SimpleContextListener()
        {
            IContext context = CreateContext("TestContext");

            IDispatcher      dispatcher = context.Dispatcher;
            IMessageComposer composer   = context.MessageComposer;

            ListenerA listener = new ListenerA();

            dispatcher.RegisterListenerForAll(listener);


            PayloadA plA = new PayloadA();
            PayloadB plB = new PayloadB();

            var message = composer.Compose(plA, plB);

            dispatcher.Send(message);
            dispatcher.DispatchMessages();
        }
コード例 #2
0
        private static void SameProcessRemoteCommunicatorTest()
        {
            IContext contextA = CreateContext("ContextA");
            IContext contextB = CreateContext("ContextB");

            SameProcessRemoteCommunicator communicatorA = new SameProcessRemoteCommunicator();
            SameProcessRemoteCommunicator communicatorB = new SameProcessRemoteCommunicator(communicatorA);

            RemoteDispatcherProxy proxyA = CreateRemoteDispatcher(contextA, communicatorA);
            RemoteDispatcherProxy proxyB = CreateRemoteDispatcher(contextB, communicatorB);

            PayloadA plA = new PayloadA();
            PayloadB plB = new PayloadB();

            var message = contextA.MessageComposer.Compose(plA, plB);

            contextA.Dispatcher.Send(message);
            contextA.Dispatcher.DispatchMessages();

            proxyB.ForwardRemoteMessages();
            contextB.Dispatcher.DispatchMessages();
        }