简体   繁体   English

如何从另一个线程访问winform控件?

[英]How to access to winform controls from the other thread?

For examle, I want to change text in the textBox from the method of the other class. 例如,我想从另一个类的方法更改textBox中的文本。 How should I do it? 我该怎么办?

You can only access WinForm controls from the thread that created them (the same is true in WPF). 您只能从创建它们的线程访问WinForm控件(在WPF中也是如此)。 But there is a mechanism inbuilt to help you: Invoke . 但是有一种内置的机制可以帮助您: Invoke

See this question for examples: WinForms interthread modification 有关示例,请参见此问题: WinForms线程间修改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM