Is there any difference between using Invoke for the parent form or for the target control?

女生的网名这么多〃 提交于 2019-12-10 15:21:04

问题


What's the difference between check InvokeRequired and call Invoke method for a control and for the parent form if I want to deal with the control from another thread?

if (theForm.InvokeRequired)
    Invoke(...)

Or

if (myControl.InvokeRequired)
   myControl.Invoke(...)

From 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.


回答1:


These two have the same effect. You can assume the form and the control were created on the same thread.



来源:https://stackoverflow.com/questions/4154380/is-there-any-difference-between-using-invoke-for-the-parent-form-or-for-the-targ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!