If I run my Program.exe
from an existing command line window, then when it finishes and exits, the Console Output is still there and viewable.
If I just double click my Program.exe
, then it'll open a new command line window, for Console Output ... but when my exe finishes, that window will close, taking the Outputs with it.
In the latter case, to prevent loss of output logs, I might want to have the final 2 lines of my Main()
be Console.WriteLine("Press any key to exit"); Console.ReadKey();
But if I do that in the former case then it's mildly annoying.
Is there any way to detect the difference between those 2 scenarios, so that I can do that "wait for the user to say I can close" conditionally ... only if necessary?