Proper way to exit a WinForms Application.
Posted on 2009-05-04
I am curious about some of the ways others exit their WinForms apps. For my application, I have a form that is similar to a splash screen that displays initially...gathers some parms from other systems, displays info and allows the user to continue. At that point the users are at the Main Form, and if it closes, I want everything else to stop, be cleaned up and exit.
I have read about Application.Exit() and Environment.Exit(0), but I am not sure I really want to use either. I don't really have to many forms and I only will have 3 additional threads running at any given time through the use of BackgroundWorkers. I was looking at having references to the open forms in the main form and just checking those on Form.Closing()...
I am just curious what some other thoughts are and maybe lessons learned... I will split the points between the top 2 selected. Any links you want to provide are appreciated, as I have no trouble reading on my own.