类型Crossthread操作的异常 [英] exception of type Crossthread operation

查看:349
本文介绍了类型Crossthread操作的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

详细信息:
从创建该线程的线程之外的其他线程访问的跨线程操作无效的控件组合框.

我正在检查if(combobox.selectedindex == 0)是否进行其他操作,但异常引发了任何建议.避免此异常的任何建议

Details:
Cross thread operation not valid control combobox accessed from a thread other than the thread it was created on.

i am checking if(combobox.selectedindex==0)in event to do other operation but exception was raising .any suggestions to avoid this exception

推荐答案

您需要使用ControlDispatcherInvokeBeginInvoke方法.

您将在我过去的答案中找到足够的细节:
Control.Invoke()与Control.BeginInvoke() [ ^ ]
Treeview Scanner和MD5的问题 [如何获取keydown事件在vb.net中的不同线程上操作 [
You need to use Invoke or BeginInvoke method of Control or Dispatcher.

You will find enough detail in my past Answers:
Control.Invoke() vs. Control.BeginInvoke()[^]
Problem with Treeview Scanner And MD5[^]

For more information:
How to get a keydown event to operate on a different thread in vb.net[^]

The applications of the Inquirers are all different, but you need to understand Invocation, first of all.
No calls to any members of UI classes can be done from any threads except the UI thread (in WPF, too). Invocation mechanism put all data and delegate instance needed to the call in the queue. The actual call is always done in UI thread, that''s it.

—SA


这篇关于类型Crossthread操作的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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