This article describes the implementation method of WinForm cross-thread access control in C#, and is shared with you for your reference.
The specific implementation method is as follows:
1. Cross-thread access control delegates and class definitions
using ;
namespace
{
/// <summary>
/// Delegation of cross-thread access control
/// </summary>
public delegate void InvokeDelegate();
/// <summary>
/// Cross-thread access control class
/// </summary>
public class InvokeUtil
{
/// <summary>
/// Cross-thread access control
/// </summary>
/// <param name="ctrl">Form object</param>
/// <param name="de">Trust</param>
public static void Invoke(Control ctrl, Delegate de)
{
if ()
{
(de);
}
}
}
}
2. Usage
In the threading method of the file:
{
= false;
= false;
= false;
= false;
= false;
};
(this, invokeDelegate);
I hope this article will be helpful to everyone's C# programming.