<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>张逸·捷道咨询-当弱引用对象成为集合元素时</title><link>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html</link><generator>RainbowSoft Studio Z-Blog 1.8 Arwen Build 81206</generator><language>zh-CN</language><pubDate>Wed, 04 Mar 2009 21:01:55 +0800</pubDate><item><title>Re:当弱引用对象成为集合元素时</title><author> (Eri)</author><link>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt39</link><pubDate>Thu, 12 Mar 2009 20:52:12 +0800</pubDate><guid>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt39</guid><description><![CDATA[“且该对象并不会被频繁使用”<br/>这个比较重要。]]></description></item><item><title>Re:当弱引用对象成为集合元素时</title><author> (tansm)</author><link>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt31</link><pubDate>Thu, 05 Mar 2009 18:02:12 +0800</pubDate><guid>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt31</guid><description><![CDATA[微软的企业库里面不是有个很好的弱引用字典的实现吗？作者涉猎不光啊。<blockquote><div class="quote quote3"><div class="quote-title">张逸 于 2009-3-5 19:04:33 回复</div>多谢赐教，我确实涉猎不广。<br/><br/>我从来都不认为自己是知识广博的人。</div></blockquote>]]></description></item><item><title>Re:当弱引用对象成为集合元素时</title><author> (pzm)</author><link>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt29</link><pubDate>Thu, 05 Mar 2009 09:34:51 +0800</pubDate><guid>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt29</guid><description><![CDATA[if (i &lt; 0 || i &gt;= this.Count)  <br/>        {<br/>            if (m_list[index].Target != null)<br/>            {<br/>                return (T)m_list[index].Target;<br/>            }<br/><br/>请问i是什么?<blockquote><div class="quote quote3"><div class="quote-title">张逸 于 2009-3-5 9:46:45 回复</div>哎呀，不好意思，将index写成i了。<br/><br/>已经改正。</div></blockquote><blockquote><div class="quote quote3"><div class="quote-title">pzm 于 2009-3-5 10:36:24 回复</div>if (index &lt; 0 || index &gt;= this.Count)  <br/>        {<br/>这样的话这个逻辑是不是有问题啊?<br/><br/>if (index &gt; 0 &amp;&amp; index &lt;= this.Count)  <br/>这样判断才正确吧<br/></div></blockquote><blockquote><div class="quote quote3"><div class="quote-title">张逸 于 2009-3-5 19:02:08 回复</div>还是你细心，昨天晚上写的，看来头有点昏，频犯低级错误。我已经修正过来了。不过如你写的index &gt; 0也不正确。所以我还是使用原来的表达式，只是调整了else的顺序。</div></blockquote><blockquote><div class="quote quote3"><div class="quote-title">pzm 于 2009-3-6 10:03:14 回复</div>呵呵 不好意思,正如你说的那样,我写的那个逻辑也不正确.<br/>if (index &gt;= 0 &amp;&amp; index &lt; this.Count) 这样才正确.<br/>当然你现在的这种写法也是对的.</div></blockquote>]]></description></item><item><title>Re:当弱引用对象成为集合元素时</title><author>uvxwp@hotmail.com (uvxwp)</author><link>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt28</link><pubDate>Thu, 05 Mar 2009 02:24:59 +0800</pubDate><guid>http://www.agiledon.com/post/2009/03/Weakreference-Collection-CSharp.html#cmt28</guid><description><![CDATA[//Singleton pattern implemented<br/>public sealed class CachingService<br/>{<br/>   //syncIndicator. -- thread synchonization<br/>   private static readonly object syncObject = new object(); <br/> <br/>   //The unique instance. -- volatile to allow multi-threading<br/>   private static volatile CachingService serviceInstance; <br/>   <br/>   //Blank default constructor<br/>   private CachingService(){}<br/>   <br/>   public static CachingService Value    <br/>   {<br/>     get<br/>     {<br/>       //in multi-threads, the next statement result will be different, <br/>       //because of the execution sequence<br/> <br/>       if(serviceInstance == null) <br/>       {<br/>         lock(syncObject)<br/>         {<br/>            if(serviceInstance == null)<br/>               serviceInstance = new CachingService();<br/>         }<br/>       }<br/>       return serviceInstance;<br/> <br/>     }//end of get<br/>   }//end of Value property<br/>}<br/>]]></description></item></channel></rss>
