将多个Control.BeginInvoke / Invoke的调用顺序执行? [英] Will multiple Control.BeginInvoke/Invoke calls execute in order?

查看:422
本文介绍了将多个Control.BeginInvoke / Invoke的调用顺序执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道Control.BeginInvoke和Control.Invoke调用是否会在它们被调用的顺序执行。

I need to know whether Control.BeginInvoke and Control.Invoke calls will execute in the order they are called.

我有以下情形:

  1. 在UI线程被阻塞
  2. 在WCF线程调用Control.BeginInvoke
  3. 在WCF线程调用Control.Invoke(或可能的BeginInvoke再次)
  4. 在UI线程畅通
  5. ??

步骤1-4的执行顺序是保证所显示的顺序(在技术上的顺序是不能保证是这样的,但这个问题我已经是如果订单数量为只显示相关的)。

The execution order of step 1-4 is guaranteed to be in the shown order (technically the order is not guaranteed to be that way, but the question I have is only relevant if the order is as shown).

我的问题是,是否有在步骤3中的调用/的BeginInvoke调用的BeginInvoke的调用之前在步骤2执行的任何机会呢?

The question I have is whether there is any chance that the Invoke/BeginInvoke call in step 3 is executed before the BeginInvoke call in step 2?

另外,请不要阻塞UI线程评论。

Also, please don't comment on blocking the UI thread.

推荐答案

在你的情况下,第2步将始终UI线程将在已排队的顺序执行的步骤3的BeginInvoke之前执行。

In your case, step 2 will always execute before step 3. BeginInvoke on the UI thread will execute in the order it has been queued.

的UI线程实际上是一个消息泵,它具有与只有一个线程消费它一个消息队列,因此它保证工作项目将在它们被排队的顺序来执行。

The UI thread is in fact a message pump, it has a single message queue with only one thread consuming it, so it's guaranteed that work items will be executed in the order they were queued.

这是一个与Delegate.BeginInvoke该执行顺序可以是非连续的。

It's with Delegate.BeginInvoke that the order of execution may be non-sequential.

这篇关于将多个Control.BeginInvoke / Invoke的调用顺序执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆