如何解决“跨线程操作无效:控制'comboBoxWeb'是从不是在其上创建线程的线程访问的.问题? [英] How to resolve the "Cross-thread operation not valid: Control 'comboBoxWeb' accessed from a thread other than the thread it was created on." problem?

查看:234
本文介绍了如何解决“跨线程操作无效:控制'comboBoxWeb'是从不是在其上创建线程的线程访问的.问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决跨线程操作无效:从创建该线程的线程以外的其他线程访问控件"comboBoxWeb".

How to resolve the "Cross-thread operation not valid: Control ''comboBoxWeb'' accessed from a thread other than the thread it was created on." problem?

推荐答案

您的代码正在尝试访问其他线程中的UI元素;这在C#中是不允许的.将所有UI代码保留在创建控件的线程中,并将后台线程用于其他目的.可能会找到一些评论和建议
Your code is trying to access a UI element in a different thread; this is not allowed in C#. Keep all your UI code in the thread where the control is created and use background threads for other purposes. Some comments and suggestions may be found here[^].


^ ]

http://c-sharp-programming.blogspot.com/2008/07/cross-thread-operation-not-valid.html[^]

http://www.itjungles.com/dotnet/fixed-cross-thread-operation-not-valid-control-accessed-from-a-thread-other-than-the-thread-it-was-created-on[^]


这篇关于如何解决“跨线程操作无效:控制'comboBoxWeb'是从不是在其上创建线程的线程访问的.问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆