现在的位置: 首页 > 综合 > 正文

delegate

2013年04月11日 ⁄ 综合 ⁄ 共 425字 ⁄ 字号 评论关闭
 public void showMsg(string msg)
        {
            if (label1.InvokeRequired)
            {
                OutDelegate d = new OutDelegate(showMsg);
                this.Invoke(d, new object[] { msg });
                return;
            }
            else
            {
                label1.Text = msg;
            }          
        }
 
        public delegate void OutDelegate(string text);
 
 
  private void NewMethod2()
        {
//业务逻辑
 
调用   showMsg(i.ToString());
 
}
 
    Thread thread = new Thread(new ThreadStart( NewMethod2));
            thread.Start();
 

抱歉!评论已关闭.