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

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

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

2019-11-14 14:18:33
字體:
供稿:網(wǎng)友

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

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

  替代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); 
   } 
   } 
  }
轉(zhuǎn)載自:http://www.aspnetjia.com/Cont-172.html

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 久久久国产一级片 | 国产精品刺激对白麻豆99 | 精品亚洲免费 | 国产精品伊人久久 | 2021国产精品视频 | 91网页视频入口在线观看 | 亚洲乱搞 | 毛片免费看的 | 美女又黄又www | 99国产精品国产免费观看 | 精品999www| 狠狠干天天操 | 欧美69free性videos | 久久草在线视频国产 | omofun 动漫在线观看 | 一区二区三区视频在线 | 毛片在线免费播放 | 日本综合久久 | 成人区精品一区二区婷婷 | 欧美成在线视频 | 国产精品二区高清在线 | 91 视频网站 | 一区二区精品在线 | 午夜国产福利 | 丁香天堂网| 精品国产一区在线观看 | 日本爽快片100色毛片视频 | 中文有码一区二区 | 少妇一级淫片免费看 | 韩国一大片a毛片 | 3级毛片 | 久久99精品久久久久久青青日本 | 久久精品亚洲欧美日韩精品中文字幕 | 依依成人综合 | 九九热在线精品视频 | 欧美一级黄色免费看 | www.91在线| 天海翼四虎精品正在播放 | chinesegv男男猛男无套 | 91女上位 在线播放 性欧美日本 | 九九黄色|