检查控件的InvokeRequired
和调用Invoke
方法有什么区别
如果我想处理来自另一个线程的控件,对于父窗体?
if (theForm.InvokeRequired)
Invoke(...)
或者
if (myControl.InvokeRequired)
myControl.Invoke(...)
来自 MSDN :
The Invoke method searches up the control's parent chain until it finds a control or form that has a window handle if the current control's underlying window handle does not exist yet.
最佳答案
这两个是一样的效果。您可以假设表单和控件是在同一个线程上创建的。
关于c# - 对父窗体或目标控件使用 Invoke 之间有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4154380/