Silverlight Dispatcher 类
生活随笔
收集整理的這篇文章主要介紹了
Silverlight Dispatcher 类
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Dispatcher?類當前只提供從非用戶界面 (UI) 線程在 UI 上運行代碼的支持。
您可以通過?DependencyObject.Dispatcher?和?ScriptObject.Dispatcher?屬性訪問 UI 線程的?Dispatcher?對象。這些方法是實例方法,但這些類型的實例無法頻繁從非 UI 線程訪問。但是,該應用程序的?Deployment?對象是?DependencyObject,并且它可通過其?Current?屬性用于任何線程。
您可以調用?CheckAccess?方法以確定調用方是否處于 UI 線程上。如果調用方不處于 UI 線程上,則可以調用?BeginInvoke?以便對 UI 線程運行指定的委托。
private delegate void AddTextDelegate(Panel p, String text);private void AddText(Panel p, String text) {p.Children.Clear();p.Children.Add(new TextBlock { Text = text }); }private void TestBeginInvokeWithParameters(Panel p) {if (p.Dispatcher.CheckAccess()) AddText(p, "Added directly.");else p.Dispatcher.BeginInvoke(new AddTextDelegate(AddText), p, "Added by Dispatcher."); }轉載于:https://www.cnblogs.com/jeekun/archive/2011/04/24/2025996.html
總結
以上是生活随笔為你收集整理的Silverlight Dispatcher 类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj 1230
- 下一篇: ZOJ 1970 All in All