微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Silverlight - 在非UI线程中使用Dispatcher更新UI对象

象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

 

以上链接中有代码示例。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐