Open two console windows from C#

So you can do multiple console windows within one single C# windows app, but to do so you would have to have a few things. Process.start(), and command-line parameters.

If you do it this way you can have your app create another instance of itself, but with different command line parameters to have each part do different things.

Here is a simplistic example of how to do it.

    namespace Proof_of_Concept_2
    {
        class Program
        {
            static void Main(string[] args)
            {
                if (args.Length!= 0)
                {
                    if (args[0] == "1")
                    {
                        AlternatePathOfExecution();
                    }
                    //add other options here and below              
                }
                else
                {
                    NormalPathOfExectution();
                }
            }


            private static void NormalPathOfExectution()
            {
                Console.WriteLine("Doing something here");
                //need one of these for each additional console window
                System.Diagnostics.Process.Start("Proof of Concept 2.exe", "1");
                Console.ReadLine();

            }
            private static void AlternatePathOfExecution()
            {
                Console.WriteLine("Write something different on other Console");
                Console.ReadLine();
            }

        }
    }

Here is a screenshot of it working. enter image description here

In conclusion,

Getting 2 console windows is easy, getting them to talk to each other is a separate question in and of itself. But I would suggest named pipes. Relevant Stackoverflow Post

You have to change your thinking because the 2 Consoles once run on different processes don't automatically talk to each other. Whatever calculation you are doing on one of them, the other one is completely unaware.


You can do

Process.Start("cmd.exe");

as many times as you would like. Is this what you mean?

Tags:

C#

Cmd