Quick note for reviewers: Since my question was randomly closed and marked as an "exact" duplicate, I was forced unfortunately to make this question again. Please actually read the problem before randomly marking and closing the question as an exact duplicate of a WinForms issue in which the solution does not work for me. Especially an out of date answer that I wouldn't get a response to if I needed clarification anyway. I'll be happy to add some clarification if necessary. :)
I just want my question the ability to be actually answered by other users, don't just needlessly close my question because you think an answer that works for an entirely different application structure, works. Make sure that the answer that you provide actually works before closing.
I feel as though I'm missing something extremely simple/stupid here so forgive me if this is a dumb question. To summarize:
I created a Windows Application. All of the stuff in the application works as intended. This Windows Application however can also utilize the command line interface by accepting switches which will then invoke some of of the methodology within the application. I got that working as intended as well.
So let's say for example I run the application in the command line like MyApp.exe -help
. The application will output the results to the Console as expected. However, whenever I write to the console, it always waits for me to press Enter before it actually returns to the state in which I can run other commands. i.e.
C:\Users\user\Desktop>_
The extremely stripped down version of the code, for visual purposes would be:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if(e.Args.Length > 0)
{
AttachConsole(-1);
Console.WriteLine("Pretend this a helpful message");
}
else
{
new MainWindow().ShowDialog();
}
Shutdown();
}
}
How can I make it not do this?
This isn't a showstopper or anything, it's just something that's annoying me and would be nice to resolve. I'm also slightly thinking ahead to when I run batch scripts upon my application; if not returning to the default console will have any repercussions.
Thanks in advance if anyone can help point me in the right direction.