Can you have multiple .net Consoles (as in Console.Writeline)

后端 未结 4 903
無奈伤痛
無奈伤痛 2020-12-11 06:59

It would be handy during debugging to have multiple consoles (not multiple monitors, which I already have). I am imagining something like Console.WriteLine(1, String1) whic

4条回答
  •  我在风中等你
    2020-12-11 07:30

    Nope

    A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console. A process can use the FreeConsole function to detach itself from its current console, then it can call AllocConsole to create a new console or AttachConsole to attach to another console.

    [http://msdn.microsoft.com/en-us/library/ms681944(VS.85).aspx](http://msdn.microsoft.com/en-us/library/ms681944(VS.85).aspx)

    Instead you can use WinForms or WPF to create multiple "console" windows and write a simple WriteLine method to append text to a text box or similar.

    Another option is to open a log file, and use that as your second "console".

提交回复
热议问题