欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c#后臺(tái)線程訪問前臺(tái)控件并顯示信息示例

 更新時(shí)間:2014年03月03日 16:02:55   作者:  
這篇文章主要介紹了c#后臺(tái)線程訪問前臺(tái)控件并顯示信息示例,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

//設(shè)置為后臺(tái)線程

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

//在append方法里面需要調(diào)用前臺(tái)控件

public void append(){

  // ... 業(yè)務(wù)處理  

  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導(dǎo)入成功\r\n";
}
else
{
txtMsg.Text += "\t\t\t\t" + id + "\t\t\t\t\t導(dǎo)入失敗\r\n";
}
}

相關(guān)文章

最新評(píng)論