using System.Windows.Forms; namespace TGControlPanel { /// /// Calls when all s are d /// #if !DEBUG abstract class CountedForm : ServerOpForm #else class CountedForm : ServerOpForm #endif { /// /// 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(); } } }