<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan Vice&#039;s Blog &#187; Event</title>
	<atom:link href="http://www.ryanvice.net/tag/event/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ryanvice.net</link>
	<description>Implementation notes and development techniques</description>
	<lastBuildDate>Sun, 10 Oct 2010 12:34:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simplified Event Raising Pattern in C#</title>
		<link>http://www.ryanvice.net/c/simplified-event-raising-pattern-in-c/</link>
		<comments>http://www.ryanvice.net/c/simplified-event-raising-pattern-in-c/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 13:13:49 +0000</pubDate>
		<dc:creator>Ryan Vice</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Delegate]]></category>
		<category><![CDATA[Event]]></category>

		<guid isPermaLink="false">http://www.ryanvice.net/?p=215</guid>
		<description><![CDATA[When creating events most people do something like this A much simpler approach is to instead do this which eleminates the need for the null check and eliminates the potential race conditions in multi-threaded code.]]></description>
			<content:encoded><![CDATA[<p>When creating events most people do something like this</p>
<pre class="brush: csharp; title: ; notranslate">
        public event PropertyChangedEventHandler PropertyChanged; 

        internal void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }</pre>
<p>A much simpler approach is to instead do this</p>
<pre class="brush: csharp; title: ; notranslate">

        public event PropertyChangedEventHandler PropertyChanged = delegate { };

        internal void RaisePropertyChanged(string propertyName)
        {
            // No need for null check because of empty delegate
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }</pre>
<p>which eleminates the need for the null check and eliminates the potential race conditions in multi-threaded code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ryanvice.net/c/simplified-event-raising-pattern-in-c/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

