Usually, calling windows application in command prompt does not wait its exit. Once I type myFormApp.exe
and press enter, a form will display and command prompt moves to next line immediately.
C:\> myFormApp.exe
C:\> # this line will display immediately
I know using cmd /c
will wait for application exit.
C:\> cmd /c myFormApp.exe
C:\> # this line will display after myFormApp.exe closed
But I want to waiting even in lack of cmd /c
.
Is there any way to prevent command prompt to move to new line, with editing myFormApp.exe source code?
Adding AllocConsole
to windows application will show console, but it does not make command prompt to wait exiting.
if (args.Length > 0)
{
// Command line given, display console
AllocConsole();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Any advices will be appreciated. Thanks!