示例#1
0
        /// <summary>
        /// This function will try for 5 seconds to open a named pipe ("SkylineInputPipe").
        /// If this operation is not successful, the function will exit. Otherwise,
        /// the function will print each line received from the pipe
        /// out to the console and then wait for a newline from the user.
        /// </summary>
        public void Start(string arg0)
        {
            string guidSuffix = RemoveCommandPrefix(arg0);

            List <string> args = new List <string>();

            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream("SkylineInputPipe" + guidSuffix)) // Not L10N
            {
                // The connect function will wait 5s for the pipe to become available
                try
                {
                    pipeStream.Connect(5 * 1000);
                }
                catch (Exception)
                {
                    // Nothing to output, because no connection to command-line process.
                    return;
                }

                using (StreamReader sr = new StreamReader(pipeStream))
                {
                    string line;
                    //While (!done reading)
                    while ((line = sr.ReadLine()) != null)
                    {
                        args.Add(line);
                    }
                }
            }

            string outPipeName = "SkylineOutputPipe" + guidSuffix;            // Not L10N

            using (var serverStream = new NamedPipeServerStream(outPipeName)) // Not L10N
            {
                var namedPipeServerConnector = new NamedPipeServerConnector();
                if (!namedPipeServerConnector.WaitForConnection(serverStream, outPipeName))
                {
                    return;
                }
                using (var sw = new CommandStatusWriter(new StreamWriter(serverStream)))
                {
                    RunCommand(args.ToArray(), sw);
                }
            }
        }
示例#2
0
        /// <summary>
        /// This function will try for 5 seconds to open a named pipe ("SkylineInputPipe").
        /// If this operation is not successful, the function will exit. Otherwise,
        /// the function will print each line received from the pipe
        /// out to the console and then wait for a newline from the user.
        /// </summary>
        public void Start(string arg0)
        {
            string guidSuffix = RemoveCommandPrefix(arg0);

            List<string> args = new List<string>();
            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream("SkylineInputPipe" + guidSuffix)) // Not L10N
            {
                // The connect function will wait 5s for the pipe to become available
                try
                {
                    pipeStream.Connect(5 * 1000);
                }
                catch (Exception)
                {
                    // Nothing to output, because no connection to command-line process.
                    return;
                }

                using (StreamReader sr = new StreamReader(pipeStream))
                {
                    string line;
                    //While (!done reading)
                    while ((line = sr.ReadLine()) != null)
                    {
                        args.Add(line);
                    }
                }
            }

            string outPipeName = "SkylineOutputPipe" + guidSuffix; // Not L10N
            using (var serverStream = new NamedPipeServerStream(outPipeName)) // Not L10N
            {
                var namedPipeServerConnector = new NamedPipeServerConnector();
                if (!namedPipeServerConnector.WaitForConnection(serverStream, outPipeName))
                {
                    return;
                }
                using (var sw = new CommandStatusWriter(new StreamWriter(serverStream)))
                {
                    RunCommand(args.ToArray(), sw);
                }
            }
        }