C# 后台线程更新UI控件

/*********************************************************************************
 *                         C# 后台线程更新UI控件
 * 说明:
 *     C#多线程更新UI控件的方法,每次都要找,记录一下,方便检索。
 *
 *                                              2017-10-23 深圳 南山平山村 曾剑锋
 ********************************************************************************/

一、参考文档:
    1. How to update textbox on GUI from another thread [duplicate]
        https://stackoverflow.com/questions/1136399/how-to-update-textbox-on-gui-from-another-thread
        
二、示例
    1. 代码:
        private void dealProgressValue(int value)
        {
            MethodInvoker action = delegate { dealProgress.Value = value; };
            ShowMessage.BeginInvoke(action);
        }
    2. 说明:
        dealProgress、ShowMessage都是UI控件。

 

posted on 2017-10-23 19:14  zengjf  阅读(1703)  评论(0编辑  收藏  举报

导航