using System.Windows.Forms; namespace TGS.ControlPanel { /// /// Calls when all s are d /// #if !DEBUG abstract #endif class CountedForm : ServerOpForm { /// /// The current number of active s /// static uint FormCount; /// /// Construct a . Increments /// public CountedForm() { FormClosed += CountedForm_FormClosed; ++FormCount; } /// /// Decrements . Calls if it reaches 0 /// /// The sender of the event /// The private void CountedForm_FormClosed(object sender, FormClosedEventArgs e) { if (--FormCount == 0) Application.Exit(); } } }