关于GUI控件线程访问 [英] Thread access on GUI controls

查看:102
本文介绍了关于GUI控件线程访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我演讲的题目是相当多的问题。我知道,从一个线程有限制访问GUI控件。看来,写/从其他另一个线程,主线程是不可能的控制设置的东西。

my topic is pretty much the question. I know that there limitations from a thread to access GUI controls. It seems that writing/setting something in a control from another thread other that the main thread is not possible.

但例如当我尝试读取一个复选框是否被选中有用。读一个组合框的文本不会。

But for example when I try to read whether a checkbox is checked it works. Reading a combobox's text won't.

我使用与.NET框架4个窗口的形式。

I am using windows forms with .net framework 4.

灿有人告诉我在哪里线程的限制是

Can someone tell me where the limitations for threads are?

推荐答案

UI元素只能在UI线程上进行更新 - 你可以检查则启动所需让你知道,如果你在另一个线程。

UI elements can only be updated on the UI thread - you can check if invoke required to let you know if you're on another thread.

下面是你可能会喜欢的如果需要则启动在GUI对象?

Here's a similar question you might like When is invoke required on GUI objects?

这篇关于关于GUI控件线程访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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