(1) textbox button等等控件 跨线程 使用 Action 函数 = delegate 建立 委托跨线程的方式。
Action asynsBtnDelegate = delegate
{
textBox_EEPROMInfo.AppendText(SumStr);
};
this.textBox_EEPROMInfo.Invoke(asynsBtnDelegate);
(2)还有这种建立 委托卡线程的方式。
private delegate void AddRemindDelegate(string value);
private void AddRemind(string value)
{
if (this.InvokeRequired)
{
AddRemindDelegate d = new AddRemindDelegate(AddRemind);
this.Invoke(d, value);
}
else
{
// this.listBox_remind;
// if (gStopDisp == 0)
{
listBox_remind.Items.Add(value);
listBox_remind.SelectedIndex = listBox_remind.Items.Count - 1;
listBox_remind.ClearSelected();
}
}
}
(3)还有传参数的
Action<int, bool> progress = delegate (int v, bool visible)
{
progressBar1.Visible = visible;
progressBar1.Value = v;
};