There are basically two things that can happen here.
Perhaps the winforms program is attached to the console window that created it (or to another console window, or even to a new console window, if necessary). After connecting to the console window Console.WriteLine (), etc. It works as expected. One of them is that the program immediately returns control to the console window, and then continues to write to it, so the user can also enter the console window. You can use start with the / wait option to handle this, I think.
Link to the beginning of command syntax
- Console redirected output
This is when someone transfers the output from your program elsewhere, for example.
yourapp> file.txt
Attaching to the console window in this case effectively ignores the pipeline. To do this, you can call Console.OpenStandardOutput () to get the handle to the stream to which the output should be connected. This only works if the output is transmitted through channels, so if you want to process both scenarios, you need to open the standard output and write to it and attach it to the console window. This means that the output is sent to the console window and to the channel, but this is the best solution I can find. Below is the code I use for this.
cedd
source share