Nipun Alahakoon
Nipun Alahakoon

Reputation: 2862

Form is running on processes even after close the program

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

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564323

There are many ways this could occur. Some of the more common include:

  1. If you use 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 application
  2. If you start a thread, via new 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

Related Questions