c# - 对父窗体或目标控件使用 Invoke 之间有什么区别吗?

标签 c# winforms multithreading invoke

检查控件的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/

相关文章:

java - ConcurrentMap 条目同步而不阻塞整个 map

linux - mmap 是原子的吗?

c++ - 线程安全 std::vector push_back 和 reserve

c# - 将 Texture2D 转换为 OpenCV Mat?

c# - 屏幕截图捕获和显示

c# - 使用 ISDN 调制解调器 (C#) 在第一次 bip 后调用电话号码时挂断

c# - 简单的 Windows 窗体数据绑定(bind)

c# - 如何使用应有的自定义断言并维护特定于调用站点的断言消息?

c# - ASP.NET 网页问题

c# - 打开 "known file type"进入自定义应用程序的运行实例 - .NET