Esempio n. 1
0
        public void PipeServer_WhenPreparingShutdown_MessagesAreRejected()
        {
            CreateSessionPipe();
            const string message = "test";

            var reset = new ManualResetEvent(false);

            _pipeServer.Start();

            var pipeClient = PipeClient.CreateSessionPipeClient(_pipeName);

            _pipeServer.PrepareShutdown();

            var success = pipeClient.SendMessage(message);

            Assert.IsFalse(success);
        }
Esempio n. 2
0
        private bool TrySendPipeMessage()
        {
            _logger.Debug("Found another running instance of clawPDF, so we send our data there");

            var message = ComposePipeMessage();

            var pipeClient = PipeClient.CreateSessionPipeClient(ThreadManager.PipeName);

            if (pipeClient.SendMessage(message))
            {
                _logger.Debug("Pipe message successfully sent");
                return(true);
            }

            _logger.Warn("There was an error while communicating through the pipe");
            return(false);
        }
Esempio n. 3
0
        public void PipeServer_SessionPipeClientSendsMessage_MessageIsReceived()
        {
            CreateSessionPipe();
            const string message = "test";

            var reset = new ManualResetEvent(false);

            _pipeServer.OnNewMessage += (sender, e) =>
            {
                if (e.Message == message)
                {
                    reset.Set();
                }
            };
            _pipeServer.Start();

            var pipeClient = PipeClient.CreateSessionPipeClient(_pipeName);

            pipeClient.SendMessage(message);
            Assert.IsTrue(reset.WaitOne(200));
        }