<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" 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/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by DinoViehland</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/DinoViehland/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by DinoViehland</title>
		<link>http://channel9.msdn.com/Niners/DinoViehland/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/DinoViehland/Discussions</link>
	<language>en</language>
	<pubDate>Wed, 19 Jun 2013 19:15:24 GMT</pubDate>
	<lastBuildDate>Wed, 19 Jun 2013 19:15:24 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - is &#39;new object().property&#39; or &#39;new object().method()&#39; a good idea?</title>
		<description><![CDATA[<p><blockquote>
<div class="quoteAuthor">littleguru wrote:</div>
<div class="quoteBody">&#65279;<br /><br />The MyObject instance won't be collected by the GC if you are accessing any fields that held by that instance... otherwise - as said - it would be a heavy CLR (GC) bug!</div>
</blockquote>
<br /><br />Just to shed a little light on the situation the typical example of this is using IntPtr's and the Dispose pattern.&nbsp; Such as:<br /><br />class MyDisposable : IDisposable {<br />&nbsp;&nbsp;&nbsp; private IntPtr _foo;<br />&nbsp;&nbsp;&nbsp; public void DoIt() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SomePInvokeOperation(_foo);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;~MyDisposable() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dispose();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp; public void Dispose() {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseMyHandle(_foo);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GC.SuppressFinalization(this);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br />Now you do: new MyDisposable().DoIt();&nbsp; The IntPtr is read and right after that read there are no longer any references to the MyDisposable() instance.&nbsp; Before SomePInvokeOperation can run the GC kicks in and&nbsp;collects the MyDisposable class.&nbsp; Next the finalizer
 thread runs which runs the finalizer&nbsp;which closes the native resource.&nbsp; Finally your SomePInvokeOperation runs and is operating on a _foo that is no longer valid.<br /><br />The worst case scenario here is that you can use this for a handle recycling attack which violates security.&nbsp; If you're lucky the app is just going to crash.&nbsp; Anyway, the way to fix this is to put a GC.KeepAlive(this); in DoIt() so that the object survives
 the lifetime of the call.&nbsp; But it's really only a problem when you're interacting with native resources which the GC doesn't understand and keep alive its self.&nbsp; So still not a bug, but a good thing to know about if you're doing any interop programming.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/259414-is-new-objectproperty-or-new-objectmethod-a-good-idea/42fa4b4480bf4ac0a7db9dfa00865c30#42fa4b4480bf4ac0a7db9dfa00865c30</link>
		<pubDate>Tue, 04 Dec 2007 03:28:33 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/259414-is-new-objectproperty-or-new-objectmethod-a-good-idea/42fa4b4480bf4ac0a7db9dfa00865c30#42fa4b4480bf4ac0a7db9dfa00865c30</guid>
		<dc:creator>DinoViehland</dc:creator>
		<slash:comments>41</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/DinoViehland/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Doing the same thing for multiple exception types</title>
		<description><![CDATA[<p>The first and last forms are the best.&nbsp; The middle one is actually different from the VB one.&nbsp;
<br /><br />The key here is the the difference between catches, finally's, and filters and when they run.&nbsp; There are two passes to exception handling (<a href="http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx">http://blogs.msdn.com/cbrumme/archive/2003/10/01/51524.aspx</a>).&nbsp;
 The catch runs on the 2nd pass, but the filter (the when clause in VB) runs on the 1st pass - that's also where finally's run.&nbsp; Catching an exception (interrupting the 1st pass) and rethrowing is generally considered bad.&nbsp; For example you interrupt the debugging
 experience and&nbsp;you raise a 2nd exception (and exceptions aren't cheap).&nbsp; There's probably other reasons out there as well.<br /><br />So 1 or 3, never 2.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/258486-Doing-the-same-thing-for-multiple-exception-types/2ff568485acf4e60b27c9df901039755#2ff568485acf4e60b27c9df901039755</link>
		<pubDate>Thu, 25 Oct 2007 03:58:12 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/258486-Doing-the-same-thing-for-multiple-exception-types/2ff568485acf4e60b27c9df901039755#2ff568485acf4e60b27c9df901039755</guid>
		<dc:creator>DinoViehland</dc:creator>
		<slash:comments>24</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/DinoViehland/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>