多线程 更新 winform 控件的值,以避免UI线程的卡顿

 

委托

private delegate void UpdateDGV_AddRes_CallBack(Int32 i,bool Res);

 

 

函数实现

private void UpdateDGV_DevAddResult(Int32 i, bool Res)
{
            if (this.DGV_DevAddResult.InvokeRequired)
            {
                UpdateDGV_AddRes_CallBack d = new UpdateDGV_AddRes_CallBack(UpdateDGV_DevAddResult);
                this.Invoke(d, new object[] { i ,Res});
            }
            else
            {
                //具体功能代码...
                //如,textbox1.text=“hello,world”

            }     
}

 

 

 

子线程这样调用:

UpdateDGV_DevAddResult(i,Res);

 

posted on 2018-06-21 16:27  陈德洲  阅读(249)  评论(0编辑  收藏  举报

导航