Let's say I launched multiples winforms from Program.cs with
Form1 form1 = new Form1();
form1.show();
Form2 form2 = new Form2();
form2.show();
Application.Run();
How do I quit application when all forms are closed by User ?
I can of course put Application.Exit() in FormClosed event but it's not very elegant I think. Are there other ways ?
Update: I mean it's not elegant to hard code each FormClosed each I have to add a new form. So is there a way I can HOOK ANY FormClosed event globally so that I can maintain the code in a central event handler without doing the PLUMBING BY HAND.
In some frameworks like Wordpress you can capture any event for any object globally I want the same kind of thing.