麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

簡單介紹.Net3.0中跨線程訪問控件

2019-11-14 14:28:46
字體:
來源:轉載
供稿:網友

這兩天用WPF做一個項目的UI部分時,發現跨線程地訪問了UI控件,自然地報異常了。當時找了半天也沒在控件中找到InvokeRequired屬性和Invoke方法,郁悶之極.....最后發現在.net3.0中,這有所改變了。

  替代InvokeRequired的方法是DispatcherObject.Checkaccess()或DispatcherObject.VerifyAccess()方法,用于指示當前線程是否可以直接訪問控件。

  替代Invoke的方法是DispatcherObject.Dispatcher.BeginInvoke(...)方法。

  參考代碼:

 

  // Uses the DispatcherObject.CheckAccess method to determine if 
  // the calling thread has access to the thread the UI object is on 
  PRivate void TryToUpdateButtonCheckAccess(object uiObject) 
  { 
   Button theButton = uiObject as Button; 
   
   if (theButton != null) 
   { 
   // Checking if this thread has access to the object 
   if(theButton.CheckAccess()) 
   { 
   // This thread has access so it can update the UI thread 
   UpdateButtonUI(theButton); 
   } 
   else 
   { 
   // This thread does not have access to the UI thread 
   // Pushing update method on the Dispatcher of the UI thread 
   theButton.Dispatcher.BeginInvoke(DispatcherPriority.Normal, 
   new UpdateUIDelegate(UpdateButtonUI), theButton); 
   } 
   } 
  }
轉載自:http://www.aspnetjia.com/Cont-172.html

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 操碰网 | 午色影院 | 91性高湖久久久久久久久网站 | 中文字幕精品在线播放 | 粉嫩粉嫩一区二区三区在线播放 | 黄色av片在线观看 | 亚洲视频在线免费看 | 91精品国产综合久久久动漫日韩 | 国产精品久久久久久久午夜片 | 黄污网站在线 | 亚洲视屏在线 | 黄色高清免费网站 | 欧美国产91 | 中文字幕22页 | 欧美成人午夜 | 精品国产乱码久久久久久丨区2区 | 亚洲日本韩国精品 | 91精品国产毛片 | 国产精品视频海角社区88 | 欧美成人激情 | 国产一国产精品一级毛片 | 91国内精品久久久久免费影院 | 日韩做爰视频免费 | 草莓福利社区在线 | 黄视频网站免费观看 | 久久国产精品久久久久久久久久 | 国产影视 | 黄色va视频 | 中文字幕免费一区 | 久久久久久久久浪潮精品 | 欧美日韩国产成人在线 | 九九热精品在线 | 韩国三级日本三级香港三级黄 | 蜜桃成品人免费视频 | 一区二区三区欧美日韩 | 黄色7777| 史上最强炼体老祖动漫在线观看 | 久久99国产精品久久99果冻传媒 | 欧美18一19sex性护士农村 | av在线播放免费观看 | 99热99精品 |