【问题标题】:Control.Invoke() vs. Control.BeginInvoke() [duplicate]Control.Invoke() 与 Control.BeginInvoke() [重复]
【发布时间】:2011-06-29 15:05:01
【问题描述】:

可能重复:
What's the difference between Invoke() and BeginInvoke()

首先,由于英语不是我的母语,我想为我的语法错误道歉。

这是我的理解:

Control.Invoke(delegated_method)  // Executes on the thread wich the control was created on
witch holds its handle ,typically  this would be the main thread of a winform application .

Control.BeginInvoke(delegated_method // Executes asynchronously on a threadPool Thread .

根据MSDN,它说

异步执行委托 控件的线程 基础句柄创建于。

我的问题:

我理解beginInvoke在这件事上把主线程当作线程池对待,当它“有机会”时在主线程上执行委托方法?

提出的另一个问题, 是否可以在主线程上创建控件? 如果是这样,有人可以给我一个例子吗?

【问题讨论】:

  • 你的语法比大多数以英语为母语的人都好;但是,您需要返回并接受一些问题的答案(点击您认为最佳答案旁边的绿色复选标记)

标签: c#


【解决方案1】:

是的,它将在创建它的 UI 线程的调度程序上执行。

至于在后台线程上创建控件,我不建议这样做。此外,您还没有提到您正在使用什么技术。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-13
    • 2015-09-30
    • 1970-01-01
    • 2013-02-26
    • 1970-01-01
    • 2010-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多