示例#1
0
        private static void ExecuteThread()
        {
            Debug.WriteLine("\n*** Named pipe server stream starting (" + Program.PROCESS_PIPE_NAME + ") ***\n");

            var pipeServer = new NamedPipeServerStream(Program.PROCESS_PIPE_NAME, PipeDirection.InOut, 1);
            int threadId   = Thread.CurrentThread.ManagedThreadId;

            while (run)
            {
                pipeServer.WaitForConnection();

                try
                {
                    StreamString ss       = new StreamString(pipeServer);
                    var          incoming = ss.ReadString();

                    Debug.WriteLine("Incoming command from pipe: " + incoming);
                    ss.WriteString("OK");
                    pipeServer.Disconnect();

                    if (incoming.Length <= 0)
                    {
                        continue;
                    }

                    string[] commandParts = incoming.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    CommandProcessor.Process(commandParts);
                }
                catch (IOException e)
                {
                    Debug.WriteLine("\n*** ERROR - Named pipe server stream failed, exception details follow [will try to continue] (" + Program.PROCESS_PIPE_NAME + ") ***\n\n {0} \n\n", e.Message);

                    try
                    {
                        pipeServer.Disconnect();
                    }
                    catch (Exception) { }
                }
            }
        }
示例#2
0
        private static void ExecuteThread()
        {
            Debug.WriteLine("\n*** Named pipe server stream starting (" + Program.PROCESS_PIPE_NAME + ") ***\n");

            var pipeServer = new NamedPipeServerStream(Program.PROCESS_PIPE_NAME, PipeDirection.InOut, 1);
            int threadId = Thread.CurrentThread.ManagedThreadId;

            while (run)
            {
                pipeServer.WaitForConnection();

                try
                {
                    StreamString ss = new StreamString(pipeServer);
                    var incoming = ss.ReadString();

                    Debug.WriteLine("Incoming command from pipe: " + incoming);
                    ss.WriteString("OK");
                    pipeServer.Disconnect();

                    if (incoming.Length <= 0)
                    {
                        continue;
                    }

                    string[] commandParts = incoming.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    CommandProcessor.Process(commandParts);
                }
                catch (IOException e)
                {
                    Debug.WriteLine("\n*** ERROR - Named pipe server stream failed, exception details follow [will try to continue] (" + Program.PROCESS_PIPE_NAME + ") ***\n\n {0} \n\n", e.Message);

                    try
                    {
                        pipeServer.Disconnect();
                    }
                    catch (Exception) { }
                }
            }
        }
示例#3
0
        public string Read()
        {
            var ss = new StreamString(pipeClient);

            return(ss.ReadString());
        }
示例#4
0
        public void Send(string data)
        {
            var ss = new StreamString(pipeClient);

            ss.WriteString(data);
        }
示例#5
0
 public void Send(string data)
 {
     var ss = new StreamString(pipeClient);
     ss.WriteString(data);
 }
示例#6
0
 public string Read()
 {
     var ss = new StreamString(pipeClient);
     return ss.ReadString();
 }