C#BeginInvoke线程方法更改UI界面

  在上位机的设计过程中,有的时候需要增加些曲线显示,UI界面更改等操作。

  在上位机上,从下位机接收到数据以后,不能直接在串口接收的线程中更改上述操作,会出现错误,这个

时候采用BeginInvoke线程方法,便可以杰觉这个问题。

  

//封装委托
private void UpdateStatus(string a)
{
    this.MCUSendDataProcessing(a);
}

//事件委托出去
private delegate void UpdateStatusDelegate(string a);

//在使用时,调用
this.BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[] {receive});

  

  

原文地址:https://www.cnblogs.com/achao123456/p/6338015.html