5
stdin 및 stdout을 통해 서로 통신 할 수 있도록 두 개의 C# 프로세스를 어떻게 연결할 수 있습니까? > 표준 출력의 A - -> 표준 입력의 B ---> 프로세스 Bstdin 및 stdout을 통한 C# 양방향 IPC
프로세스 < - 표준 입력 < - 표준 출력의 B < --- 프로세스
프로세스 A :이처럼
B
stdin 및 stdout을 통해 서로 통신 할 수 있도록 두 개의 C# 프로세스를 어떻게 연결할 수 있습니까? > 표준 출력의 A - -> 표준 입력의 B ---> 프로세스 Bstdin 및 stdout을 통한 C# 양방향 IPC
프로세스 < - 표준 입력 < - 표준 출력의 B < --- 프로세스
프로세스 A :이처럼
B
using System;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
string name;
if (args.Length > 0 && args[0] == "slave")
{
name = "slave";
}
else
{
name = "master";
var info = new ProcessStartInfo();
info.FileName = "BidirConsole.exe";
info.Arguments = "slave";
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
var other = Process.Start(info);
Console.SetIn(other.StandardOutput);
Console.SetOut(other.StandardInput);
}
Console.WriteLine(name + " started.");
while (true)
{
var incoming = Console.ReadLine();
var outgoing = name + " got : " + incoming;
Console.WriteLine(outgoing);
System.Threading.Thread.Sleep(100);
}
}
}