Windows 10, C#, .NET Core 3.1
I want to have multiple console windows for output. For example, on one display I want to place the one console window which will display errors only output, on other display I want to place the set of other console windows which will display various reports. All these console windows are to be read only. Also, at the same time I want to have the main console window which I will use as the terminal (for keyword input). I saw the similar in the films about programmers and want try to do the same :)
I expected I can create the child processes and write into Input each of them from the parent process. I expected each child process will have its own console window, but I see they use the console window of the main process.
This is my main application code:
using System;
using System.Diagnostics;
namespace ConsoleClient
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Console app...";
Console.WriteLine("This is the message for the main console application.");
var procInfo = new ProcessStartInfo(
@".\logger\ConsoleLogger.exe");
procInfo.UseShellExecute = false;
procInfo.RedirectStandardInput = true;
procInfo.CreateNoWindow = false;
using (var proc = new Process())
{
proc.StartInfo = procInfo;
proc.Start();
var sw = proc.StandardInput;
sw.WriteLine("This is the message for the child console application.");
Console.WriteLine("Press ENTER for exit...");
Console.ReadLine();
proc.Kill();
}
}
}
}
This is my child application code:
using System;
using System.Diagnostics;
namespace ConsoleLogger
{
class Program
{
static void Main(string[] args)
{
Console.Title = $"Process #{Process.GetCurrentProcess().Id} (logger)";
while (true)
{
var line = Console.In.ReadLine();
Console.WriteLine(line);
}
}
}
}
The result is the common console window for both processes (parrent and child):
How can I solve it?
UPD
I think the problem is in RedirectStandardInput
using. I try to find other solution.