Semantically, you are incorrect, even though in most cases that would work. What you stated will exit the Application Loop that that Application represents. For multiple Application Loops, the must all be terminated.
If you're application consists of of a main form (i.e. one created by using Application.Run(new Form()); ) then closing that form exits the application. Although, if you're doing it programaticly, then I wouldn't use that.
You probably have another thread created that is not running as a background thread which will stop your application from closing until the thread aborts. You probably need to review if this is this case, or upload your project demonstrating the behavior.
Please do not respond to this thread -- create a new one.
Please do not resurrect threads that are years old. By doing so you run the risk of confusing current posters. If you have any questions please ask. You are welcome to start your own threads. Have a look at forum rules.
this.Close() and also this.Dispose() causes an exception.
Then I'd wager you have a problem in your cleanup code. Environment.Exit() probably works because it terminates the process in an unclean way for form applications. I'd further speculate that Application.Exit() fails as well, because it cleanly ends the application.
In other words, your code is broken. Trace the exception and find out where it's coming from, then fix the problem. The closing issue will be resolved as well.
I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...
i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried ...