プロセスとの通信に名前付きパイプを使用しています。次のコードで動作させることができました。(元のコードはここにあります:archive.org経由)
class ProgramPipeTest
    {
        public void ThreadSenderStartClient(object obj)
        {
            // Ensure that we only start the client after the server has created the pipe
            ManualResetEvent SyncClientServer = (ManualResetEvent)obj;
            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(".","ToSrvPipe",PipeDirection.Out,PipeOptions.None))
            {
                // The connect function will indefinately wait for the pipe to become available
                // If that is not acceptable specify a maximum waiting time (in ms)
                pipeStream.Connect();
                Console.WriteLine("[Client] Pipe connection established");
                using (StreamWriter sw = new StreamWriter(pipeStream))
                {
                    sw.AutoFlush = true;
                    string temp;
                    Console.WriteLine("Please type a message and press [Enter], or type 'quit' to exit the program");
                    while ((temp = Console.ReadLine()) != null)
                    {
                        if (temp == "quit") break;
                        sw.WriteLine(temp);
                    }
                }
            }
        }
        public void ThreadStartReceiverClient(object obj)
        {
            // Ensure that we only start the client after the server has created the pipe
            ManualResetEvent SyncClientServer = (ManualResetEvent)obj;
            using (NamedPipeClientStream pipeStream = new NamedPipeClientStream(".", "FromSrvPipe", PipeDirection.In, PipeOptions.None))
            {
                // The connect function will indefinately wait for the pipe to become available
                // If that is not acceptable specify a maximum waiting time (in ms)
                pipeStream.Connect();
                Console.WriteLine("[ClientReceiver] Pipe connection established");
                using (StreamReader sr = new StreamReader(pipeStream))
                {
                    // Display the read text to the console
                    string temp;
                    while ((temp = sr.ReadLine()) != null)
                    {
                        Console.WriteLine("Received from server: {0}", temp);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            // To simplify debugging we are going to create just one process, and have two tasks
            // talk to each other. (Which is a bit like me sending an e-mail to my co-workers)
            ProgramPipeTest Client = new ProgramPipeTest();
            Thread ClientThread = new Thread(Client.ThreadSenderStartClient);
            Thread ReceivedThread = new Thread(Client.ThreadStartReceiverClient);
            ClientThread.Start();
            ReceivedThread.Start();
        }
    }
すべてが意図したとおりに機能します。ターゲットプロセス(audacity)にコマンドを発行できます。
私の問題は、基本的にこのコードの周りにC#GUIをラップしたいのですが、コマンドがGUIまたはコードから発行されるため、コンソールを使用せずに通信が行われるように変更する方法がわかりません。
streamWriter swをクラス変数に変換し、プロパティを介して公開し、メソッドを使用してsw.WriteLine()を呼び出してみましたが、うまくいかないようです。
そのため、オブジェクト内でストリームを適切に前後にカプセル化する方法がわかりません。
この記事は、名前付きパイプを使用してGUIをWindowsのコンソールアプリに接続するのにぴったりのように見えましたが、残念ながら、コードが付属していないようで、参照する必要がありません。
では、コマンドを発行するためにコンソールを使用せずに、名前付きパイプを使用するにはどうすればよいですか?