![]() ![]() If this is the situation that you're in then you'll need to add more details to your question describing what types of applications should and should not actually end the program. In such a case you will need to just hide your main form rather than closing it, but you'll need to add in some sort of mechanism that will actually close the main form when you really do want your app to end. If you want to be able to have the user click the "x" for your main form, but have another form stay open and, in effect, become the "new" main form, then it's a bit more complicated. EXIT /b has the option to set a specific. If you are showing them again, then hiding them may be fine. To close an interactive command prompt, the keyboard shortcut ALT + F4 is an alternative to typing EXIT. 12 Answers Sorted by: 38 If the Java app does not terminate (e.g. As for all of the other forms, if you don't intend to show that same instance of the form again you just just let them close, rather than preventing closure and hiding them. This is different from closing a bat, or exiting it using goto :EOF or Exit /b. Try move nul to nowhere and redirect the stderr to stdin will result in the current window cmd.exe being closed. By not canceling that event and just letting them form close when the user closes it you will get your desired behavior. To close the current cmd windows immediately, just add as the last command/line: move nul 2>&0. If your entire application should always fully terminate whenever your main form is closed then you should just remove that form closed handler. The entire application will end when the main form (the form started via Application.Run in the Main method) is closed (not hidden). Does that affect how my application is behaving now? whenever my forms call the formclosed or form closing event I close the applciation with a this.Hide() function. Reference: Why would Application.Exit fail to work?īy the way. If true, then Run has been called and you can assume that a WinForms application is executing as follows. This value can be tested in batch files where ERROR LEVEL gives us the return value provided by the exit () function. You can determine if .Run has been called by checking the .MessageLoop property. The syntax for using the exit () function is given below, exit( exitvalue ) Here, exitvalue is the value passed to the Operating system after the successful termination of the program. Environment.Exit, points towards a good tip: This is the code to call when you are using console application. Terminates this process and gives the underlying operating system the specified exit code. This is the code to use if you are have called Application.Run (WinForms applications), this method stops all running message loops on all threads and closes all windows of the application. ![]() Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |