//设置为后台线程

Thread th = new Thread(delegate() {
  append();
});
th.IsBackground = true;
th.Start();

//在append方法里面需要调用前台控件

public void append(){

  // ... 业务处理  

  this.Invoke(new flushMessage(showMessage), new object[] { row["Code"].ToString(), res });
}

//委托flushMessage和方法showMessage签名必须一致
private delegate void flushMessage(String id, String res);
private void showMessage(String id,String res)
{
if (res == "true")
{
txtMsg.Text += "\t\t\t\t" + id + "\t\t\t\t导入成功\r\n"; 
}
else
{
txtMsg.Text += "\t\t\t\t" + id + "\t\t\t\t\t导入失败\r\n";
}
}

 

相关文章:

  • 2022-12-23
  • 2021-07-02
  • 2021-08-31
  • 2021-10-22
  • 2021-06-17
  • 2021-12-23
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2018-01-18
  • 2021-12-23
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案