mirror of
https://github.com/kwsch/NHSE.git
synced 2026-10-01 14:26:38 -05:00
Clean up imagefetcher for net10/cross thread safety
This commit is contained in:
22
NHSE.WinForms/Util/CrossThreadExtensions.cs
Normal file
22
NHSE.WinForms/Util/CrossThreadExtensions.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user