问题描述
你好,
Control.BeginInvoke(Delegate):在创建控件的基础句柄的线程上异步地"执行指定的委托" ".该委托被异步调用.您可以从任何线程调用此方法,"甚至是拥有控件句柄的线程."
用粗体引用上述文本,如果我们调用主线程中的任何控件的BeginInvoke方法(正在忙于执行其他一些任务)会发生什么呢?
会有两个线程吗?
还是对BeginInvoke的调用将等待主线程完成其执行任务?如果是这样,那么如果主线程的执行任务非常耗时,则UI可能会进入非响应状态.
Hello,
Control.BeginInvoke(Delegate) : Executes the specified delegate "asynchronously on the thread" that the control''s underlying handle was created on. The delegate is called asynchronously. You can call this method from any thread, "even the thread that owns the control''s handle."
Referring the above texts in bold, what will happen actually if we call BeginInvoke method of any control in the Main Thread ( which is busy executing some other tasks)?
Will there be two threads?
Or this call to BeginInvoke will wait for Main thread to complete its executing task? if so, then UI may go into nonresponding state if the executing task of Main Thread is quite time consuming.
推荐答案
这篇关于调用control.BeginInvoke时实际上会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!