mirror of
https://github.com/kwsch/NHSE.git
synced 2026-03-22 01:34:51 -05:00
22 lines
459 B
C#
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();
|
|
}
|
|
}
|
|
} |