Reputation: 2862
I was created a C# program using 2 forms. I add both of them a exit button with close(); method.But when i run the executable file , even if i close the program with exit button still the program run on processes at task manger. I believe its something related with one form closing but the other one was loaded to the memory and not stopping. Such situations. how come we terminate the complete program without it not storing at memory? close(); method not enough?
Upvotes: 1
Views: 1085
Reputation: 564323
There are many ways this could occur. Some of the more common include:
Application.Run()
(instead of Application.Run(someForm)
) to start the application, it will run until you call Application.Exit
or use another method to shut it down. Closing the forms will not shut down the applicationnew Thread
, and don't make it a background thread, that will also keep the program alive. Processes will stay alive until all foreground threads have completed. You can work around this by making the thread a background thread (or using the Task
class instead of a Thread
).Upvotes: 2