NHSE/NHSE.WinForms/Util/CrossThreadExtensions.cs
2026-01-17 02:34:59 +00:00

22 lines
459 B
C#

using System;
using System.Windows.Forms;
namespace NHSE.WinForms;
public static class CrossThreadExtensions
{
/// <summary>
/// Helper function to perform an action on a Control's thread safely.
/// </summary>
public static void PerformSafely(this Control target, Action action)
{
if (target.InvokeRequired)
{
target.Invoke(action);
}
else
{
action();
}
}
}