开发者

Open a new console application while running the existing console app) [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Is there a way to create a second console to output to in .NET when writing a console application?

How to open a new console application (2) while running the existing console app (1)?

static void Main(strin开发者_运维百科g[] args)
{
    try
    {
       Console.WriteLine("success"); 

       //how to close this console          
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error Due To: " + ex.Message);
    }
    finally
    {
        //code for opening the second console....(is that passible)
        //how to close this console
    }                   
}


See Process Class

System.Diagnostics.Process.Start()

Edit: Something like that, but you have to notice that this will create a new instance of the application every time the previous version closed! (is that what you want?)

class Program
{
    static void Main(string[] args)
    {
        try
        {
            Console.WriteLine("success");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error Due To: " + ex.Message);
        }
        finally
        {
            //code for opening the second console....(is that passible)
            System.Diagnostics.Process.Start("ConsoleApplication15.exe");
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜