c# – 跨线程Winforms控件编辑
发布时间:2020-12-15 20:05:05 所属栏目:百科 来源:网络整理
导读:参见英文答案 Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on????????????????????????????????????20个 如果正在编辑文本的代码“属于”包含Windows窗体的单独线程,如何编辑windows窗体元素中
参见英文答案 >
Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on????????????????????????????????????20个
如果正在编辑文本的代码“属于”包含Windows窗体的单独线程,如何编辑windows窗体元素中的文本?我得到了例外:
谢谢. 解决方法
你需要使用这样的
Control.Invoke方法:
textbox1.Invoke((MethodInvoker)(() => { textbox1.Text="some text"; })); 也请查看这篇文章:Threading in UIs (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |