Correct way to exit an Winform application?

  • Thread starter Thread starter sune42
  • Start date Start date
S

sune42

What is the "Correct" way to exit an Winform application?

I have used

Application.Exit();

But I find that the application is still running in TaskManager after
closing it,
so I asume that I am doing something wrong here..

Any ideas?
 
Windows processes are removed from memory when there is no more runing
threads in them. If you have worker threads make sure that they have
finished before closing the application. Alternatively when you start a
thread you can set IsBackground property to *true* so the the threads will
be killed upon exiting the application; otherwise they will keep working,
thus locking the process in the memory.

The normal way of exiting an application is to stop all worker threads as
well as all UI threads. The UI threads are stopped when the main form's
Close method is called (this ends to message loop). I personally never liked
this Application.Exit. It looked to me too brutal. However I see that in
..NET 2.0 they made it more polite :), so now it looks OK to be used.
 
Back
Top