<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: EventArgs: No need to pass a new Instance</title>
	<atom:link href="http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/feed/" rel="self" type="application/rss+xml" />
	<link>http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/</link>
	<description>Adam&#039;s view on technology, software development, and world domination.</description>
	<lastBuildDate>Sat, 28 Jan 2012 23:17:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Adam</title>
		<link>http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/comment-page-1/#comment-126</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Mon, 25 Sep 2006 04:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/#comment-126</guid>
		<description>After discussing this topic with a few other people, the true cost of using &#039;New EventArgs&#039; became a bit more clear. It&#039;s a matter of scope, and a matter of garbage collection.

Since a new instance would fall out of scope when the method call ends (and thus make its way to the GC), and EventAgrs.Empty will remain in memory (as it wont fall out of scope). That explains a large part of the expense involved.

So with that fact in mind, I can see where using EventArgs.Empty could have a more significant impact. With as often as events are called and the number of otherwise useless EventArgs that could end up in memory, yeah, EventArgs.Empty is the way to go.</description>
		<content:encoded><![CDATA[<p>After discussing this topic with a few other people, the true cost of using &#8216;New EventArgs&#8217; became a bit more clear. It&#8217;s a matter of scope, and a matter of garbage collection.</p>
<p>Since a new instance would fall out of scope when the method call ends (and thus make its way to the GC), and EventAgrs.Empty will remain in memory (as it wont fall out of scope). That explains a large part of the expense involved.</p>
<p>So with that fact in mind, I can see where using EventArgs.Empty could have a more significant impact. With as often as events are called and the number of otherwise useless EventArgs that could end up in memory, yeah, EventArgs.Empty is the way to go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/comment-page-1/#comment-125</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Mon, 25 Sep 2006 04:08:06 +0000</pubDate>
		<guid isPermaLink="false">http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/#comment-125</guid>
		<description>That&#039;s a good point Syntax, though I would have to wonder if the impact would be that significant.

Most instances of EventArgs are fairly short-lived, they will only be in memory for a relatively short amount of time. Unless the code uses a rather large number of events, seems to me the impact either way will be fairly small.

For certain architectures though I can see that it may be a more significant impact, a proper implementation of MVC tends to be quite heavy when it comes to event code. In those situations, I guess I could see it possibly being more significant.

I may have to do some testing, figure out just how expensive the call really is.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a good point Syntax, though I would have to wonder if the impact would be that significant.</p>
<p>Most instances of EventArgs are fairly short-lived, they will only be in memory for a relatively short amount of time. Unless the code uses a rather large number of events, seems to me the impact either way will be fairly small.</p>
<p>For certain architectures though I can see that it may be a more significant impact, a proper implementation of MVC tends to be quite heavy when it comes to event code. In those situations, I guess I could see it possibly being more significant.</p>
<p>I may have to do some testing, figure out just how expensive the call really is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Syntax</title>
		<link>http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/comment-page-1/#comment-124</link>
		<dc:creator>Syntax</dc:creator>
		<pubDate>Mon, 25 Sep 2006 03:55:26 +0000</pubDate>
		<guid isPermaLink="false">http://adamcaudill.com/2006/09/24/eventargs-no-need-to-pass-a-new-instance/#comment-124</guid>
		<description>EventArgs.Empty does _not_ just call the constructor.  It&#039;s a static field, so that every time you reference it you are using the same object.

This has the advantage that you are saving an object creation every time it is used.  With event heavy code, this can be a large win.

(Of course, the _real_ solution to this is to have the compiler identify that the object will never be changed from the default state, and handle this optimisation transparently.  I&#039;m not sure this analysis is actually tractable in general, however).</description>
		<content:encoded><![CDATA[<p>EventArgs.Empty does _not_ just call the constructor.  It&#8217;s a static field, so that every time you reference it you are using the same object.</p>
<p>This has the advantage that you are saving an object creation every time it is used.  With event heavy code, this can be a large win.</p>
<p>(Of course, the _real_ solution to this is to have the compiler identify that the object will never be changed from the default state, and handle this optimisation transparently.  I&#8217;m not sure this analysis is actually tractable in general, however).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

