I'm facing a problem with the console portion of my app not waiting for the program to finish before accepting a new command. This is an app that has optional command line run mode with no GUI like many others have described before. I check for certain conditions when running and determine if I should use the GUI or if I should "attach to the console that called the program".
[DllImport("kernel32.dll")]
static extern bool AttachConsole(int dwProcessId);
private const int ATTACH_PARENT_PROCESS = -1;
if (args.Length > 1) { AttachConsole(ATTACH_PARENT_PROCESS); }
(I got the gist of this code from Stack Overflow, but could not locate the OP)
So if I Console.Writeline("this string here"), then it will write to the window that started the program what I tell it to.
I would like to stop that window from accepting user input while my program is running, so I can continually feed out to the window without being interrupted.
For example, when you do an ip config command, you cannot make any more commands from that window, until everything has been written to the window.
I'm fairly certain after thorough searching that this is a unique question. Should it be found otherwise please refer me to that question.
**Note, I don't want "Press any key to continue" functionality. I want it to make the user wait until the application finishes then re-enable the console window for user input.
-Thank you kindly!