Multiple Consoles in a Single Console Application

前端 未结 1 1893
臣服心动
臣服心动 2021-02-14 18:17

I have created a C# Project which has multiple console applications in it. Now my question is: Is it possible to display multiple consoles when I run one application?

相关标签:
1条回答
  • 2021-02-14 19:07

    Here's a quick example of what can be done... obviously, adjust paths to your liking and there are a few other ways:

    Preview:

    enter image description here

    Code:

    using (var process1 = new Process())
    {
        process1.StartInfo.FileName = @"..\..\..\ConsoleApp1\bin\Debug\ConsoleApp1.exe";
        process1.Start();
    }
    
    using (var process2 = new Process())
    {
        process2.StartInfo.FileName = @"..\..\..\ConsoleApp2\bin\Debug\ConsoleApp2.exe";
        process2.Start();
    }
    
    Console.WriteLine("MainApp");
    Console.ReadKey();
    

    This was a quick setup and many things can be and should be adjusted (exception handling, etc., etc., etc.). It should get you started, though.

    0 讨论(0)
提交回复
热议问题