using System; using System.Threading.Tasks; using System.Windows.Forms; namespace TGS.ControlPanel { /// /// Used to provide an ATP function for calls into an /// #if !DEBUG abstract #endif class ServerOpForm : Form { /// /// 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.Run(action); } finally { Enabled = true; UseWaitCursor = false; } } } }