Example #1
0
        void PushCommands()
        {
            try
            {
                string name = "npp.css.dbg.commands." + remoteProcessId;
                using (var pipeServer = new NamedPipeServerStream(name, PipeDirection.Out))
                    using (var streamWriter = new StreamWriter(pipeServer))
                    {
                        pipeServer.WaitForConnection();
                        Notify("Out.Client connected.");
                        streamWriter.AutoFlush = true;

                        while (true)
                        {
                            string command = MessageQueue.WaitForCommand();

                            streamWriter.WriteLine(command);
                            if (command == NppCommand.Exit)
                            {
                                MessageQueue.AddNotification(NppCommand.Exit); //signal to stop the PullNotifications channel
                                break;
                            }
                            pipeServer.WaitForPipeDrain();
                        }
                    }
            }
            catch
            {
            }

            Notify("Out.Client disconnected.");
        }