mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 06:27:19 +01:00
Sanely namespaces the project
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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 class ServerOpForm : Form
|
||||
#else
|
||||
class ServerOpForm : Form
|
||||
#endif
|
||||
{
|
||||
/// <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.Factory.StartNew(action);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Enabled = true;
|
||||
UseWaitCursor = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user