9

I want to have a new console open whenever I create a new thread so that the output will be organized. My application is fully console based. Would this be possible if so how?

Regards!

Arya
  • 8,473
  • 27
  • 105
  • 175

3 Answers3

16

A process can be associated with only one console

http://msdn.microsoft.com/en-us/library/windows/desktop/ms681944(v=vs.85).aspx

L.B
  • 114,136
  • 19
  • 178
  • 224
0

It's not difficult to work around this limitation.

The code that you want to run as a separate thread with its own console window, simply code that as a separate console application, passing parameters as required on the command line.

Then run separate instances of this code using Start() inside your main application.

0

I have managed to get this working replacing the TextWriter (Console.SetOut()) and storing the values into a ThreadLocal

Then when you get the values from your TextWriter they are per thread

Matt Peters
  • 1,171
  • 1
  • 8
  • 16