C# WINFORM 子线程更新UI

获取当前线程 

System.Threading.Thread.CurrentThread.ManagedThreadId

//判断是否创建句柄
            if (this.IsHandleCreated)
            {
                MethodInvoker inf = new MethodInvoker(ShowDesktopInfo);
                BeginInvoke(inf);          
            }

//更新UI

 private void ShowDesktopInfo()
        {

            if (ServerData.UserInfo != null)
            {


                this.lb_Name.Text = ServerData.UserInfo.TrueName;

}

}

猜你喜欢

转载自blog.csdn.net/LUOCHENLONG/article/details/83823947