应用程序调度程序和控制调度程序 [英] Application Dispatcher and Control Dispatcher

查看:96
本文介绍了应用程序调度程序和控制调度程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有名称为 button1的控制按钮和名称为 doSomething的功能。函数 doSomething是从另一个线程调用的。

Assume i have control button with name "button1" and function with name "doSomething". Function "doSomething" is called from another thread.

我有两种方法可以从UI线程调用函数doSomething。

i have two method to call function doSomething from UI thread.

首先,从控制按钮调度程序中

First, from control button dispatcher

this.button1.Dispatcher.BeginInvoke(new Action(() => { doSomething(); }));

其次,来自应用程序调度程序

and Second, from application dispatcher

this.Dispatcher.BeginInvoke(new Action(() => { doSomething(); }));

结果相同,真正的不同是什么?

The result is same, what is the real different ?

推荐答案

在同一线程拥有的所有控件中都引用了相同的调度程序实例。没有区别。

The same dispatcher instance is referenced in all controls owned by the same thread. There is no difference.

这篇关于应用程序调度程序和控制调度程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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