mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 06:27:19 +01:00
36 lines
891 B
C#
36 lines
891 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace TGS.ControlPanel
|
|
{
|
|
/// <summary>
|
|
/// Used to provide an ATP function for calls into an <see cref="TGS.Interface.IServerInterface"/>
|
|
/// </summary>
|
|
#if !DEBUG
|
|
abstract
|
|
#endif
|
|
class ServerOpForm : Form
|
|
{
|
|
/// <summary>
|
|
/// Used to wrap <see cref="TGS.Interface.IServerInterface"/> calls in a non-blocking fashion while disabling the <see cref="Form"/> and enabling the wait cursor
|
|
/// </summary>
|
|
/// <param name="action">The <see cref="TGS.Interface.IServerInterface"/> operation to wrap</param>
|
|
/// <returns>A <see cref="Task"/> wrapping <paramref name="action"/></returns>
|
|
protected Task WrapServerOp(Action action)
|
|
{
|
|
Enabled = false;
|
|
UseWaitCursor = true;
|
|
try
|
|
{
|
|
return Task.Run(action);
|
|
}
|
|
finally
|
|
{
|
|
Enabled = true;
|
|
UseWaitCursor = false;
|
|
}
|
|
}
|
|
}
|
|
}
|