using System; using System.Threading.Tasks; using System.Windows.Forms; namespace TGControlPanel { /// /// Used to provide an ATP function for calls into an /// #if !DEBUG abstract class ServerOpForm : Form #else class ServerOpForm : Form #endif { /// /// Used to wrap calls in a non-blocking fashion while disabling the and enabling the wait cursor /// /// The operation to wrap /// A wrapping protected Task WrapServerOp(Action action) { Enabled = false; UseWaitCursor = true; try { return Task.Factory.StartNew(action); } finally { Enabled = true; UseWaitCursor = false; } } } }