<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>More info on 'using' and resource management</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx</link><description>Joe Duffy (PM on the CLR team) posted to my blog about the whole using/resource management subject. Being an cool and froody guy (who i may or may not have ever met) he linked back to a great post of his own on the subject *and* included even more information</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>bla</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx#456248</link><pubDate>Thu, 25 Aug 2005 18:03:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:456248</guid><dc:creator>Ivailo</dc:creator><description>Your blog is realy very interesting. &lt;a rel="nofollow" target="_new" href="http://www.g888.com"&gt;http://www.g888.com&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=456248" width="1" height="1"&gt;</description></item><item><title>re: More info on 'using' and resource management</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx#427196</link><pubDate>Thu, 09 Jun 2005 13:15:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:427196</guid><dc:creator>Qflash</dc:creator><description>RePost:&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://www.yeyan.cn/Programming/usingresourcemanagement.ASPX"&gt;http://www.yeyan.cn/Programming/usingresourcemanagement.ASPX&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=427196" width="1" height="1"&gt;</description></item><item><title>re: More info on 'using' and resource management</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx#416981</link><pubDate>Thu, 12 May 2005 23:37:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:416981</guid><dc:creator>Pilchie (Kevin Pilch-Bisson)</dc:creator><description>And the above would only work if the compiler changed the code gen so that the expression and assignment happen inside the try block.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=416981" width="1" height="1"&gt;</description></item><item><title>re: More info on 'using' and resource management</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx#416976</link><pubDate>Thu, 12 May 2005 23:33:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:416976</guid><dc:creator>Pilchie (Kevin Pilch-Bisson)</dc:creator><description>Wait, that won't work. (because the assignment will still not be protected by the finally.&lt;br&gt;&lt;br&gt;How about:&lt;br&gt;&lt;br&gt;    public delegate T Creator&amp;lt;T&amp;gt;();&lt;br&gt;&lt;br&gt;    public static class ReliableFactory {&lt;br&gt;        public static IDisposable Create&amp;lt;T&amp;gt;(out T temp, Creator&amp;lt;T&amp;gt; create) where T : IDisposable {&lt;br&gt;            try { }&lt;br&gt;            finally {&lt;br&gt;                temp = create();&lt;br&gt;                return null;&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;&lt;br&gt;    class C {&lt;br&gt;        void F() {&lt;br&gt;&lt;br&gt;            using (IDisposable use = null, ignore = ReliableFactory.Create(out use, delegate { new LayoutTransaction(this, this, PropertyNames.Dock); })) {&lt;br&gt;                // stuff.&lt;br&gt;            }&lt;br&gt;        }&lt;br&gt;    }&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=416976" width="1" height="1"&gt;</description></item><item><title>re: More info on 'using' and resource management</title><link>http://blogs.msdn.com/b/cyrusn/archive/2005/05/10/416278.aspx#416970</link><pubDate>Thu, 12 May 2005 23:22:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:416970</guid><dc:creator>Pilchie (Kevin Pilch-Bisson)</dc:creator><description>What about something that took a delegate instead of a where T: new?  Then you could use anonymous methods, and locals, etc.&lt;br&gt;&lt;br&gt;Something like this:&lt;br&gt;&lt;br&gt;public delegate T Creator&amp;lt;T&amp;gt;();&lt;br&gt;&lt;br&gt;public static class ReliableFactory {&lt;br&gt;    public static T Create&amp;lt;T&amp;gt;(Creator&amp;lt;T&amp;gt; create) {&lt;br&gt;        try { }&lt;br&gt;        finally {&lt;br&gt;            return create();&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;}&lt;br&gt;&lt;br&gt;class C {&lt;br&gt;    void F() {&lt;br&gt;        using (ReliableFactory.Create(delegate { expression here); })) {&lt;br&gt;            // stuff.&lt;br&gt;        }&lt;br&gt;    }&lt;br&gt;}&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=416970" width="1" height="1"&gt;</description></item></channel></rss>