象WinForm编程一样,Silverlight中的UI对象,只能通过UI线程来更新。不同的是Silverlight提供了一个Dispatcher对象,可以方便的将background线程对UI对象的操作marshal到UI线程上。而且,可以使用任意UI对象上的Dispatcher来更新任意UI对象:
because Silverlight has a single UI thread, it has a single Dispatcher
object that holds a queue of work items for the UI. Using the
Dispatcher will allow you to update the UI from a non-UI thread.
from - http://msdn.microsoft.com/en-us/magazine/cc721609.aspx
You don't have to use the Dispatcher property of the object you intend
to update; you can use Dispatcher on any UI object to marshal the call
to the UI thread.
from - http://www.wintellect.com/CS/blogs/jprosise/archive/2008/03/26/threading-and-marshaling-in-silverlight-2-0.aspx
以上链接中有代码示例。
分享到:
相关推荐
虽然使用Dispatcher.Invoke 和模拟winform 里面的DoEvent 但是运行中关闭还是会有异常,而且耗资源高; 第二种 : DispatcherTimer 失败:UI还是会卡顿; 第三种 : Timer 建议使用、资源占用少,关闭启动自如。
WPF后台线程更新UI---http://www.tuicool.com/articles/NbieE3M
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
所以一个建议的方法是使用Dispatcher.InvokeAsync ,如果需要深入了解,请看我师傅的文章深入了解 WPF Dispatcher 的工作原理在所
plexus-sec-dispatcher-1.3.jar
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
xml里filter-mapping中的dispatcher的使
Dispatcher对象:在WPF中,每个线程都有一个Dispatcher对象,它负责在该线程上分派事件和处理操作。 MVVM模式:MVVM模式是一种设计模式,特别适用于WPF应用程序。 以上是一些常见的C#跨类跨线程访问UI线程控件的技术...
离线安装包,亲测可用
Laravel开发-dispatcher 在应用程序中计划Artisan命令
官方离线安装包,亲测可用
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用
该工具会自动为Kamailio构建一个dispatcher.list (使用 ),以便动态地负载平衡Asterisk主机,例如,当它们在CoreOS中的Fleet下运行时。 简而言之,您可以将一个实例作为对Kamailio的辅助操作(在“调度程序模式”...
在WPF中简化UI线程(使用Dispatcher)和新线程的使用
(Same as ACME Process 4 Dispatcher from the UiPath Academy). 2. Create a separate workflow file for the Login to ACME. File input arguments: URL ; Username ; Password < SecureString >. 3. Create a ...
数据库连接池
Applications which use unidirectional UI archictures have UI state passed to a single "render"-method. Sometimes it is needed to render only parts of the state which are actually changed. Diff ...
Dispatcher应用实例,在一个线程中创建的UI对象,也只能是创建该UI对象的线程才能访问它。如果其他线程要访问这个UI对象,需要通过创建UI线程的Dispatcher才能实现