在非派生自 System.Windows.Forms.Control 的类中,可以使用 SynchronizationContext 来确保线程安全地更新用户界面控件。以下是一个示例:
using System;
using System.Threading;
using System.Windows.Forms;
public class MyForm : Form
{
private Label myLabel;
public MyForm()
{
myLabel = new Label() {
Location = new System.Drawing.Point(10