Console app that opens a new window for each threa

2019-09-15 15:27发布

I have a console application that starts multiple different threads. The main console app will poll a service and based on responses it will spawn one or more background threads using the BackgroundWorker class. At the moment each of these threads do a console.writeline to the sole default console window opened as it normally does for a console application. This makes it too confusing to follow the progress of any one thread.

I want to be able to spawn a separate window with each of them writing their own console.writeline() to their own windows. When done, the main console app window will close the spawned console window, and then start it up again when it needs to.

I have not been able to find anything useful on this online. Im probably not using the correct keywords in my search. Any help in this please?

2条回答
狗以群分
2楼-- · 2019-09-15 16:06

It is not possible to have a separate console window for each thread. There can be only one console per process. You may want to look at this thread thread having its own console

查看更多
Deceive 欺骗
3楼-- · 2019-09-15 16:18

As a follow up to Vladimir's comments there's a nice sample app here that demonstrates attaching and detaching from a console and changing the display colors and locations and has some c# libraries build around the Windows Console API.

http://www.mischel.com/diary/2006/08/19.htm

查看更多
登录 后发表回答