40 lines
960 B
C#
40 lines
960 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace IOB_WIN_NEXT
|
|
{
|
|
/// <summary>
|
|
/// Helper gestione UITHread e deleghe
|
|
/// https://www.codeproject.com/Articles/37642/Avoiding-InvokeRequired
|
|
/// </summary>
|
|
internal static class ControlExtensions
|
|
{
|
|
#region Public Methods
|
|
|
|
static public void UIThread(this Control control, Action code)
|
|
{
|
|
if (control.InvokeRequired)
|
|
{
|
|
control.BeginInvoke(code);
|
|
return;
|
|
}
|
|
code.Invoke();
|
|
}
|
|
|
|
static public void UIThreadInvoke(this Control control, Action code)
|
|
{
|
|
if (control.InvokeRequired)
|
|
{
|
|
control.Invoke(code);
|
|
return;
|
|
}
|
|
code.Invoke();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |