All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP对特殊语句查询结果进行数组排序_php资料_编程技术
C#程序的50种方法
delphi获取System目录
存储过程中调用C#写的DLL_[Asp.Net教程]
PHP网站开发中关于包含路径问题的解决方案_php资料_编程技术
符合web标准的媒体播放器代码_JavaScript技术_编程技术
C#动态生成树型结构的Web程序设计_.net资料_编程技术
SQL,Server与Oracle链接服务器应用_[SQL,Server教程]
草根的进化,PHP语言发展简史_php资料_编程技术
SQL Server 2005重新安装不上的问题及其解决_[SQL Server教程]
Reading number is top 10 pictures
The hot big eye big breast beauty2
Absolutely shocked. National geographic 50 animal photographys10
全球十大灵异酒店
The hot big eye big breast beauty1
Angie Chiu vijara myth1
奇趣的世界记录1
NeedWallpaper4
Sora aoi on twitter4
The real super beauty5
The little woman's bright wire3
Download software ranking
Ashlynn Video4
Call Of Duty5
Boxer's Top ten classic battle10
Ashlynn Video5
WebService在.NET中的实战应用教学视频 → 第3集
Eclipse 4.2.2 For Win32
Unix video tutorial17
ASP.NET.2.0.XML.高级编程(第3版)
Unix video tutorial12
艳兽都市
aaa published in(发表于) 2013/12/18 8:25:05 Edit(编辑)
简单介绍.Net3.0,中跨线程访问控件_.net资料_编程技术

简单介绍.Net3.0,中跨线程访问控件_.net资料_编程技术

简单介绍.Net3.0 中跨线程访问控件_.net资料_编程技术-你的首页-uuhomepage.com

  这两天用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);
   }
   }
  }



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.