コード例 #1
0
        public static async Task <IntercomDuplexChannel <TCallback, TService> > CreateSlaveChannelAsync(TCallback callbackService, string pipeName)
        {
            using (var client = new IntercomClientChannel <IDispatcherService>(pipeName + Constants.Dispatcher))
            {
                await client.ConnectAsync();

                var name = client.Execute(Constants.DispatchMethod).ToString();

                return(new IntercomDuplexChannel <TCallback, TService>(callbackService, name, false));
            }
        }
コード例 #2
0
        public void TestChannels()
        {
            string pipeName = "Vkm.TestPipe1";

            var service = new Test1();
            IntercomClientChannel <Test1> clientChannel = new IntercomClientChannel <Test1>(pipeName);
            var task = clientChannel.ConnectAsync();
            IntercomServerChannel <Test1> serverChannel = new IntercomServerChannel <Test1>(service, pipeName);

            task.Wait();

            Assert.AreEqual(0, service.MethodCallCount);
            var r = clientChannel.Execute(nameof(Test1.Do), 5, 7);

            Assert.AreEqual(1, service.MethodCallCount);
            Assert.AreEqual(5 * 7, r);

            r = clientChannel.Execute(nameof(Test1.Do), 11, -11);
            Assert.AreEqual(2, service.MethodCallCount);
            Assert.AreEqual(-11 * 11, r);
        }