<?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/"
	xmlns:series="http://organizeseries.com/"
	>

<channel>
	<title>Anuj Varma</title>
	<atom:link href="http://www.anujvarma.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anujvarma.com</link>
	<description>Web Log of a techie, globetrotter, uber geek</description>
	<lastBuildDate>Sun, 05 May 2013 11:05:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>The Publish Subscribe Pattern in C# and some gotchas</title>
		<link>http://www.anujvarma.com/the-publish-subscribe-pattern-in-c-and-some-gotchas/</link>
		<comments>http://www.anujvarma.com/the-publish-subscribe-pattern-in-c-and-some-gotchas/#comments</comments>
		<pubDate>Wed, 17 Apr 2013 19:48:50 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[C# 4.0]]></category>
		<category><![CDATA[My Favorite SOA Patterns]]></category>
		<category><![CDATA[.net eventing]]></category>
		<category><![CDATA[c# messaging]]></category>
		<category><![CDATA[c# observer pattern]]></category>
		<category><![CDATA[c# publish subscribe]]></category>
		<category><![CDATA[c# publisher subscriber]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1440</guid>
		<description><![CDATA[NOTE: With the introduction of two new interfaces in .NET 4.0, there is a cleaner way to implement the Publish Subscribe pattern in C# .NET. However, the ‘gotchas’ listed here still apply. Even with the new interfaces, one still needs &#8230; <a href="http://www.anujvarma.com/the-publish-subscribe-pattern-in-c-and-some-gotchas/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>NOTE: With the introduction of two new interfaces in .NET 4.0, there is a <a href="http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/">cleaner way</a> to implement the <a href="http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/">Publish Subscribe pattern in C# .NET</a>. However, the ‘gotchas’ listed here still apply. Even with the new interfaces, one still needs to worry about things such as ‘unsubscribing from the publisher’, ‘badly behaved subscribers’, ‘new subscriber added while publishing is in progress’ etc.. The 4 main potential issues with any publish-subscribe implementation are summarized below. This post will discuss each issue in detail.</p>
<p>Gotcha 1 – One rotten apple – blocks the others. When multiple subscribers are present – what if one of the subscribers blocks the publisher so that it is effectively not available to other subscribers? This can easily occur if any one of the subscribers decide to do something lengthy (oh – like maybe run an infinite loop) in its event handler. How do we prevent such an occurrence? How do we prevent one rotten apple from spoiling the bunch?</p>
<p>Gotcha 2 &#8211; What if a subscriber is added while notification is in progress? Supposing the list of subscribers is being notified &#8211; and a new subscriber happens to come along (this is not a rare event &#8211; especially if any one of the subscribers happens to contain time-consuming code as in Gotcha 1) . What happens to the new subscriber? Does it get dropped? Do we add it? If so – where and when do we add it?</p>
<p>Gotcha 3 &#8211; Subscribers that fail to unsubscribe. A ‘good’ practice (maybe even a ‘best’ practice) in .NET eventing is to ensure that all subscribers eventually unsubscribe from their events – once they are done handling it. Failure to do so leads to potential memory leaks. This is actually one of the more common sources of memory leaks in .NET applications (see my blog on <a title="Common Sources of Memory Leaks in .NET Applications" href="http://cut.ms/QYE" rel="tag" target="_blank">Common Sources of Memory Leaks in .NET Applications</a>)</p>
<p>Gotcha 4 &#8211; Race conditions in the .NET eventing framework – leading to inconsistent handling of events.</p>
<p>&nbsp;</p>
<p>ORIGINAL (OLD) WAY OF IMPLEMENTING PUBLISH SUBSCRIBE in .NET (View <a href="http://www.anujvarma.com/new-interfaces-for-implementing-publish-subscribe-in-net/">this post</a> to see the new implementation)</p>
<p>The eventing mechanism built into the .NET runtime makes it a piece of cake to implement a simple publisher &#8211; subscriber pattern (C# code follows). The example below revolves around the ‘payday’ event – which is called <em>PayrollArrived</em>. The event is published by the <em>Employer</em> class (the Employer announces <em>when </em>payday arrives). Each <em>Employee</em> (i.e. each instance of the Employee class) listens for the event – and is hence a subscriber to the <em>PayrollArrived </em>event.</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><p><span style="color: #0000ff">// Publisher Class – EmployerPublisher – will publish the PayrollArrived event</span></p><p>&nbsp;</p><p><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmployerPublisher
</p></pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span>  PayrollArrivedHandler PayrollArrived;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEvent(DateTime today)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	  PayrollArrived(today); 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}  
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #008000">// Subscriber class – Employee – interested in knowing when the PayrollArrived event occurs</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> Employee
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; height: 15px; font-size: 12px">	<span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> OnPayrollArrival(DateTime day)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">       { 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">		<span style="color: #008000">// Round up some friends and go spend the money!</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">       }	 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; height: 30px; font-size: 12px">} 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #008000">// Hooking up the publisher and subscriber(s) in the client code</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">EmployerPublisher publisher = <span style="color: #0000ff">new</span> EmployerPublisher();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">Employee employee1 = <span style="color: #0000ff">new</span> Employee();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">Employee employee2 = <span style="color: #0000ff">new</span> Employee();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">publisher.PayrollArrived += employee1.OnPayrollArrival;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; height: 22px; font-size: 12px">publisher.PayrollArrived += employee2.OnPayrollArrival;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; height: 12px; font-size: 12px"><span style="color: #008000">// Now that the subscribers are hooked up, the event can be fired</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">DateTime now = DateTime.Now;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">publisher.FireEvent(now.date);</pre>
<p>&nbsp;</p>
<p>However &#8211; there are a few gotchas to watch out for:</p>
<p><font size="3"><strong>Gotcha 1</strong> – One rotten apple – blocks the others. When <em>multiple subscribers</em> are present – what if one of the subscribers <em>blocks</em> the publisher so that it is effectively not available to other subscribers?&nbsp; This can easily occur if any one of the subscribers decide to do something lengthy (oh – like maybe run an infinite loop) in its event handler. How do we prevent such an occurrence? How do we prevent one rotten apple from spoiling the bunch?</font></p>
<p><font size="3"><strong>Gotcha 2</strong> &#8211; What if a subscriber is added <em>while notification is in progress? </em>Supposing the list of subscribers is being notified &#8211; and a new subscriber happens to come along (this is not a rare event &#8211; especially if any one of the subscribers happens to contain time-consuming code as in Gotcha 1) . What happens to the new subscriber? Does it get dropped? Do we add it? If so – where and when do we add it?</font></p>
<p><font size="3"><strong>Gotcha 3</strong> &#8211; <em>Subscribers that fail to unsubscribe</em>. A ‘good’ practice (maybe even a ‘best’ practice) in .NET eventing is to ensure that all subscribers eventually unsubscribe from their events – once they are done handling it. Failure to do so leads to potential memory leaks.&nbsp; This is actually one of the more common sources of memory leaks in .NET applications (see my blog on </font><a title="Common Sources of Memory Leaks in .NET Applications" href="http://cut.ms/QYE" rel="tag" target="_blank"><font size="3">Common Sources of Memory Leaks in .NET Applications</font></a><font size="3">)</font></p>
<p><font size="3"><strong>Gotcha 4</strong> &#8211; <em>Race conditions</em> in the .NET eventing framework – leading to inconsistent handling of events.</font></p>
<p>Let us look at these one by one:</p>
<p><strong><span style="text-decoration: underline">Gotcha 1 – One rotten apple….or the badly-behaved subscriber problem </span></strong></p>
<p>The badly-behaved subscriber problem is best solved by working under the assumption that all subscribers will be badly behaved! So what is a publisher to do? One solution is to launch each notification on a new thread &#8211; that way even if a subscriber is badly behaved &#8211; it does not tie down the notification of other subscribers. Since the CLR in .NET provides a ready-made thread-pool, this is a seemingly simple solution. In fact, all one needs to do is use the built in support for asynchronous delegates (the event defined in the publisher class is really just a delegate). How would this look?</p>
<p>&nbsp;</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmployerPublisher
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span>  PayrollArrivedHandler PayrollArrived
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #008000">// This event firing is synchronous - i.e. the publisher instance is tied down until the subscriber finishes processing OnPayrollArrival</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEvent(DateTime today)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	  PayrollArrived(today); 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #008000">// This is an asynchronous version of the same event-firing - just fire it - and do not worry about how long the subscriber takes - since subscriber processing </span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #008000">// is on a different thread.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEventAsynchronous(DateTime today)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	  PayrollArrived.BeginInvoke(today, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>); 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}  </pre>
<p>We are almost there. The only problem with the above code is a C# restriction &#8211; if you want to call BeginInvoke, your delegate (our event) can only have one target. We already have two targets (employee1.OnPayrollArrival and employee2.OnPayrollArrival) &#8211; so what do we do? How about if we take our delegate and look at all its&nbsp; targets one by one &#8211; and call BeginInvoke on them one at a time? That should work around the original problem.</p>
<pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 1093px; padding-right: 5px; height: 609px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmployerPublisher
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span>  PayrollArrivedHandler PayrollArrived
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #008000">// This event firing is synchronous - i.e. the publisher instance is tied down until the subscriber finishes processing OnPayrollArrival</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEvent(DateTime today)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	  PayrollArrived(today); 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #008000">// This is an asynchronous version of the same event-firing - just fire it - and do not worry about how long the subscriber takes - since subscriber processing is on a different thread.</span>
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEventAsynchronous(DateTime today)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>)
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">      {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	 Delegate[] delegates = PayrollArrived.GetInvocationList();
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">         <span style="color: #0000ff">foreach</span>(Delegate del <span style="color: #0000ff">in</span> delegates) 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">         {
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">		PayrollArrivedHandler handler = (PayrollArrivedHandler) del;
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">               handler.BeginInvoke(today, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">null</span>) 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">         } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}    </pre>
<p>Gotcha 1 (the badly-behaved subscriber problem) &#8211; is essentially addressed by letting the subscribers stay badly behaved. We just don&#8217;t care &#8211; we&#8217;ve still managed to notify all the subscribers successfully.</p>
<p>Gotcha 2 : A subscriber is added while notification is in progress </p>
<p>This is a slightly trickier problem to solve. We still want to allow the new subscriber to add itself &#8211; but we do not want to interfere with the current notification process.</p>
<p>This solution is borrowed from <a type="amzn">Holub on Patterns </a>- and works well in our scenario as well. The basic idea is that instead of having just ANY collection of subscribers &#8211; use a linked list to store subscribers.</p>
<p>Notification of the list of subscribers boils down to traversing the linked lists one node at a time. Say you are on some intermediate node &#8211; and a new subscriber arrives. Simply add the new subscriber (as a node) to the head of the list!</p>
<p>This way &#8211; it doesn&#8217;t interfere with the existing notification process &#8211; and is successfully added to the list of subscribers whenever the next notification comes around.</p>
<p>Gotcha 2&nbsp; (subscribers added while notification is in progress) &#8211; is solved by ensuring that any new subscribers are added to the head of a linked list (containing all the subscribers)</p>
<p>Gotcha 3: Subscribers that fail to unsubscribe</p>
<p>The publisher holds a reference to every subscriber that has subscribed to its events. 2 subscribers – 2 references – 100 subscribers – hundred references. Unless each and every individual subscriber specifically unsubscribes after handling the event, the publisher does not release the reference to that subscriber. This leads to objects hanging around on the managed heap (and also potentially unmanaged resources (files, images etc.) that are held on to by the managed objects).</p>
<p>Gotcha 3 Solution – Ensure that subscribers always unsubscribe from subscribed events when they are done. </p>
<p>NOTE: WPF uses something called the ‘Weak Event Pattern’ (basically a WeakReference from the publisher to its subscribers – which gets garbage collected if it has been idle for a period of time).</p>
<p>Gotcha 4 : Race Condition in the .NET eventing framework</p>
<p>This is not a publish-subscribe problem – but more an ‘eventing’ problem in the .NET framework. This ends up being a publish-subscribe problem nevertheless.</p>
<pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> EmployerPublisher
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span>  PayrollArrivedHandler PayrollArrived;
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> FireEvent(DateTime today)
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   {
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">     <span style="color: #008000">// There is a possible race condition that can occur here</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">     <span style="color: #008000">// If another subscriber - on another thread - unsubscribes from this event,</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">     <span style="color: #008000">// the PayrollArrived suddenly becomes null</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	<span style="color: #0000ff">if</span>(PayrollArrived != <span style="color: #0000ff">null</span>) <span style="color: #008000">// WILL THROW A NULLREFERENCE EXCEPTION</span>
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">	  PayrollArrived(today); 
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">   } 
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}  
</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre>
<p>Gotcha 4 Solution– A simple workaround is to ensure that the event is always initialized to an empty delegate – this way it will never be null.</p>
<pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">event</span>  PayrollArrivedHandler PayrollArrived = <span style="color: #0000ff">delegate</span> {};</pre>
<h3>Summary</h3>
<p>.NET’s eventing framework makes it simple to create a simple Publish Subscribe solution – however – one has to be careful about certain trip hazards. None of these hazards are difficult to deal with – and with just a little due diligence, one can have a powerful messaging subsystem going within any application. Neglecting these little details can, however, cause serious problems including memory leaks, unfulfilled subscribers and even uncaught exceptions.</p>
<p><span style="text-decoration: underline">Full Source Code </span></p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:18d43e01-4549-4fde-8ca6-c7b4b7385fac:cd83037d-7d68-44fe-b0ce-392da0cc4d5f" class="wlWriterSmartContent">
<p>Download Solution &#8211; <a href="http://www.dotnetarchitectdallas.com/file.axd?file=PublishSubscribe.zip">PublishSubscribe.zip</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/the-publish-subscribe-pattern-in-c-and-some-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using CSS Templates with ASP.NET MVC</title>
		<link>http://www.anujvarma.com/using-css-templates-with-asp-net-mvc/</link>
		<comments>http://www.anujvarma.com/using-css-templates-with-asp-net-mvc/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 14:48:04 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[asp.net mvc css]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1414</guid>
		<description><![CDATA[
Find a CSS layout that you like – one good source is freecsstemplates.org.
In your MVC solution, in the shared views folders, there should be a _layout.cshtml file. This file contains razor view engine syntax. What we need to do is &#8230; <a href="http://www.anujvarma.com/using-css-templates-with-asp-net-mvc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<ol>
<li>Find a CSS layout that you like – one good source is freecsstemplates.org.</li>
<li>In your MVC solution, in the shared views folders, there should be a _layout.cshtml file. This file contains razor view engine syntax. What we need to do is incorporate the razor view tags inside the CSS template that we downloaded.&nbsp; </li>
<li>Here is a detailed <a href="http://www.youtube.com/watch?v=0O0gi2m_p_o">youtube video</a> showing how this might be done</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/using-css-templates-with-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>All flash storage cluster&#8230;database performance may take a giant leap</title>
		<link>http://www.anujvarma.com/all-flash-storage-clusterdatabase-performance-may-take-a-giant-leap/</link>
		<comments>http://www.anujvarma.com/all-flash-storage-clusterdatabase-performance-may-take-a-giant-leap/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 07:32:30 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[SQL Server, Denali]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1408</guid>
		<description><![CDATA[http://www.techpageone.com/technology/enterprise-ssd-the-first-all-flash-storage-cluster/#.UWz9oZPviSq
]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techpageone.com/technology/enterprise-ssd-the-first-all-flash-storage-cluster/#.UWz9oZPviSq">http://www.techpageone.com/technology/enterprise-ssd-the-first-all-flash-storage-cluster/#.UWz9oZPviSq</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/all-flash-storage-clusterdatabase-performance-may-take-a-giant-leap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Active Release Technique for Tennis Elbow</title>
		<link>http://www.anujvarma.com/active-release-therapy-for-tennis-elbow/</link>
		<comments>http://www.anujvarma.com/active-release-therapy-for-tennis-elbow/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 04:46:35 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Diet, Health]]></category>
		<category><![CDATA[active release tendonitis]]></category>
		<category><![CDATA[active release tennis elbow]]></category>
		<category><![CDATA[tennis elbow recovery]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1354</guid>
		<description><![CDATA[Rest your elbow &#8211; give it complete rest (goes the popular lore for treating tennis elbow). Well &#8211; I gave it complete rest. Not tennis, no golf, not even hours on my computer (only used touch screen devices).In addition, spent &#8230; <a href="http://www.anujvarma.com/active-release-therapy-for-tennis-elbow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><font size="2" face="Verdana">Rest your elbow &#8211; give it complete rest (goes the popular lore for treating tennis elbow). Well &#8211; I gave it complete rest. Not tennis, no golf, not even hours on my computer (only used touch screen devices).<br />In addition, spent months and months on conventional physiotherapy. I know every stretch/exercise ever invented for the elbow, arm and upper body.I could write a book. It would be useless though &#8211; cause all those exercises, while somewhat strengthening in nature, did nothing to lessen the pain &#8211; or cure the tendonitis. My case is not unique (a little googling will reveal cases of no-progress tennis elbow for months and months &#8211; and years on end).<br /></font></p>
<p><font size="2" face="Verdana">Having pretty much tried everything (every ointment, every pill, every accu thing &#8211; pressure, puncture&#8230;), I was fairly disillusioned at the entire medical profession. Having seen no less than 6 orthopedics and 4 top-notch physical therapy clinics, I had lost all faith.</font></p>
<p><font size="2" face="Verdana">My brain kept saying &#8211; &#8216;It can&#8217;t be THAT hard &#8211; it&#8217;s just some overused tendons/muscles close to the elbow. How hard can it be to fix that&#8217;? So &#8211; I refused to give up &#8211; and kept exploring. That&#8217;s how I came across Active Release. Once again, going in with full skepticism &#8211; since every previously &#8216;highly recommended&#8217; therapy had flopped miserably (miserably &#8211; because there after all the physical therapy and home exercises, there was less than a 20% improvement in the major symptoms).</font></p>
<p><font size="2" face="Verdana">I went to Dr. Zalinsky in Austin – a guy who specializes in Active Release Therapy &#8211; and sports injuries in particular.</font></p>
<p><font size="2" face="Verdana">His basic approach was very matter of fact &#8216;Yes- I&#8217;ve seen this a lot &#8211; and yes, let me first see if I can fix it.&#8217; </font></p>
<p><font size="2" face="Verdana">
<p>By now, I had become a complete skeptic when it came to anyone promising fixes. He did something next that completely changed my skepticism.</p>
<p>He pressed my eblow in a few tender spots, asked me to move (stretch) my arm in a few directions. First time, no result. He changes the point he is pushing &#8211; and asks me to stretch again.<br />No result again. This continues for about 5 minutes. Finally, he pushes a point on the opposite side of the elbow (one that wasn&#8217;t even hurting) &#8211; asks me to stretch &#8211; and I can instantly feel something correcting itself inside (even though it hurt like hell). </p>
<p>Now, he asks me to move my arm around. Almost no pain! Way better!. We repeated the process on the same point &#8211; and the pain was way better. It had magically subsided &#8211; although both of us knew that the relief may not be permanent &#8211; and that I would have to return.</p>
<p>Nevertheless, this was the first time (in months) &#8211; that someone had successfully used manual techniques (or any techniques) to produce an immediate reduction of pain.</font></p>
<p><font size="2" face="Verdana">&#8216;Yes &#8211; we can help you&#8217; he concluded after his 5 minute experiment. &#8216;It may take 2 sessions, it may take 4 to 6, but we can help you.&#8217;</font></p>
<p><font size="2" face="Verdana">In just two sessions, my pain was reduced by 50%, I was lifting things twice as heavy as before and not feeling the twinge. This is what my brain had being saying to me all along &#8216;It CANNOT be that hard. There has to be some way to fix this without waiting for 12 months!&#8217;</font></p>
<p><font size="2" face="Verdana">Active Release&#8217;s approach goes against the grain. &#8216;Resting&#8217; the elbow will accomplish nothing &#8211; since there is something chronically pushing against a nerve (a muscle pulling/pushing on a nerve), that is not going to quit by itself. This pushing/pulling point has to be located &#8211; and then straightened out. Unless that is done, no amount of rest will straighten it out on its own.<br />I really do not claim to understand how it all works &#8211; all I know is that it works. </font>&nbsp;</p>
<p><font size="2" face="Verdana"></font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/active-release-therapy-for-tennis-elbow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Letter to Sonia, Sheila and Rahul</title>
		<link>http://www.anujvarma.com/letter-to-sonia-sheila-and-rahul/</link>
		<comments>http://www.anujvarma.com/letter-to-sonia-sheila-and-rahul/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 03:33:41 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[India]]></category>
		<category><![CDATA[damini incident]]></category>
		<category><![CDATA[damini rape]]></category>
		<category><![CDATA[delhi rape]]></category>
		<category><![CDATA[india rape]]></category>
		<category><![CDATA[India rapes]]></category>
		<category><![CDATA[india safe women]]></category>
		<category><![CDATA[india unsafe]]></category>
		<category><![CDATA[india women]]></category>
		<category><![CDATA[indian rape]]></category>
		<category><![CDATA[new delhi rape]]></category>
		<category><![CDATA[rape capital]]></category>
		<category><![CDATA[rape gandhi]]></category>
		<category><![CDATA[woman safety]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1351</guid>
		<description><![CDATA[The rapes have to stop. Right now. Not tomorrow, not next month, not within a ‘phased timeframe’. Right now. 
All that is needed is effective policing – and enforcement of existing laws. Do not hide behind the ‘delay tactic’ of &#8230; <a href="http://www.anujvarma.com/letter-to-sonia-sheila-and-rahul/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><font size="2" face="Verdana">The rapes have to stop. Right now. Not tomorrow, not next month, not within a ‘phased timeframe’. Right now. </font></p>
<p><font size="2" face="Verdana">All that is needed is effective policing – and enforcement of existing laws. Do not hide behind the ‘delay tactic’ of enacting new laws, forming committees or blaming it on the Indian male. </font></p>
<p><font size="2" face="Verdana">If you cannot stop the rapes, step down. You have no right to be in&nbsp; your power position. This is your TOP priority – not the economy, not the upcoming election – THIS! Basic safety of citizens. In no city in&nbsp; India can a woman go out alone after dark – and feel completely secure. Not because of Indian men – but because of Indian police (or lack there-of) – and because of Indian politicians such as yourself (who are unable to ensure that the police do their job).</font></p>
<p><font size="2" face="Verdana">The rapes MUST stop. Right now. Or you must be stopped – from holding your office.&nbsp; </font></p>
<p><font size="2" face="Verdana">The choice is yours.</font></p>
<p><font size="2" face="Verdana">&nbsp;</font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/letter-to-sonia-sheila-and-rahul/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Outlook messages open up in MS Word</title>
		<link>http://www.anujvarma.com/outlook-messages-open-up-in-ms-word/</link>
		<comments>http://www.anujvarma.com/outlook-messages-open-up-in-ms-word/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 00:59:28 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Windows Quirks, Email, Internet Gotchas]]></category>
		<category><![CDATA[MS Word editor for outlook]]></category>
		<category><![CDATA[outlook messages in MS word]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1349</guid>
		<description><![CDATA[Here’s what happens – you open outlook to compose a new message (or reply to an existing one). Instead of Outlook as your editor, MS Word takes over at this point. Confusion ensues – since Word’s window is always hidden &#8230; <a href="http://www.anujvarma.com/outlook-messages-open-up-in-ms-word/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Here’s what happens – you open outlook to compose a new message (or reply to an existing one). Instead of Outlook as your editor, MS Word takes over at this point. Confusion ensues – since Word’s window is always hidden behind outlook – and at times, becomes hard to find your message in composition.</p>
<p> After struggling with this issue, found a helpful article on how to turn off this behavior in Outlook.</p>
<p>In Outlook, simply go to Tool—&gt;Options—&gt;Mail Format&nbsp;&nbsp; &#8211; and uncheck ‘Use Microsoft Word to edit e-mail messages’</p>
<p><a title="http://office.microsoft.com/en-us/outlook-help/turn-word-on-or-off-as-your-e-mail-editor-or-viewer-HP005242849.aspx" href="http://office.microsoft.com/en-us/outlook-help/turn-word-on-or-off-as-your-e-mail-editor-or-viewer-HP005242849.aspx">http://office.microsoft.com/en-us/outlook-help/turn-word-on-or-off-as-your-e-mail-editor-or-viewer-HP005242849.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/outlook-messages-open-up-in-ms-word/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Live Writer for Editing Pages</title>
		<link>http://www.anujvarma.com/windows-live-writer-for-editing-pages/</link>
		<comments>http://www.anujvarma.com/windows-live-writer-for-editing-pages/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 17:21:10 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Wordpress, Windows Live Writer and Other Blogging Tools]]></category>
		<category><![CDATA[edit page live writer]]></category>
		<category><![CDATA[edit page WLW]]></category>
		<category><![CDATA[windows live writer pages]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1342</guid>
		<description><![CDATA[Editing blog ‘posts’ is straightforward in Windows Live Writer. To get to the ‘pages’ (created in WordPress) was somewhat hidden…
Editing ‘pages’ as opposed to ‘posts’ in LiveWriter

1. FILE—&#62;Open Recent Post
You should see a side bar that contains ‘Drafts’, ‘Recently posted’ &#8230; <a href="http://www.anujvarma.com/windows-live-writer-for-editing-pages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Editing blog ‘posts’ is straightforward in Windows Live Writer. To get to the ‘pages’ (created in WordPress) was somewhat hidden…</p>
<h3>Editing ‘pages’ as opposed to ‘posts’ in LiveWriter</h3>
<ol>
<li>1. FILE—&gt;Open Recent Post</li>
<li>You should see a side bar that contains ‘Drafts’, ‘Recently posted’ and your blog name (e.g. Anuj Varma)</li>
<li>Click on your blog name. You should see the right hand side display as shown below – This contains the ‘Posts and ‘Pages’ option. </li>
<li>Select Pages and you should be able to retrieve the pages on your blog as well as edit them.</li>
</ol>
<p><a href="http://www.anujvarma.com/wp-content/uploads/editing_pages_in_windows_live_writer.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="editing_pages_in_windows_live_writer" border="0" alt="editing_pages_in_windows_live_writer" src="http://www.anujvarma.com/wp-content/uploads/editing_pages_in_windows_live_writer_thumb.png" width="669" height="237"></a></p>
<p>&nbsp;</p>
<h3>Creating New Pages</h3>
<ol>
<li>File—&gt;New Post—&gt;Page</li>
</ol>
<p><a href="http://www.anujvarma.com/wp-content/uploads/creating_new_page_WLW.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="creating_new_page_WLW" border="0" alt="creating_new_page_WLW" src="http://www.anujvarma.com/wp-content/uploads/creating_new_page_WLW_thumb.png" width="599" height="153"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/windows-live-writer-for-editing-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Page&#8211;A free editor for Cold Fusion Markup (and HTML)</title>
		<link>http://www.anujvarma.com/first-pagea-free-editor-for-cold-fusion-and-html/</link>
		<comments>http://www.anujvarma.com/first-pagea-free-editor-for-cold-fusion-and-html/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 03:48:39 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Cold Fusion]]></category>
		<category><![CDATA[free cold fusion editor]]></category>
		<category><![CDATA[getting started with cold fusion]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1334</guid>
		<description><![CDATA[More recently, I returned to some Cold Fusion programming (In the late 90s, I owned and operated coldfusionprogrammer.com – a site dedicated to Cold Fusion development&#160; &#8211; but moved to other platforms since then). 
I was pleased to see that &#8230; <a href="http://www.anujvarma.com/first-pagea-free-editor-for-cold-fusion-and-html/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>More recently, I <a href="http://www.anujvarma.com/installing-and-configuring-coldfusion-with-iis7/">returned</a> to some Cold Fusion programming (In the late 90s, I owned and operated coldfusionprogrammer.com – a site dedicated to Cold Fusion development&nbsp; &#8211; but moved to other platforms since then). </p>
<p>I was pleased to see that the development server (CFServer) was still completely free of cost (downloadable <a href="http://www.adobe.com/products/coldfusion-family.html">here</a> – choose ‘Developer Edition’).</p>
<p>The IDE (CF Builder), however, was not free. So – I started digging around – and much to my dismay, did not easily find a low cost alternative to writing CFML code. Then I came across ‘<a href="http://download.cnet.com/First-Page-2006/3000-10247_4-10490779.html">First Page’</a> – primarily an HTML editor – but one that understood CF tags as well. No bells and whistles like intellisense etc. – but at a very basic level, lets you write CFML and HTML code without any interruptions. In fact, the HTML editor is one of the most intuitive that I have seen.</p>
<p>So – with the free CF server – and the free IDE – I was up and CFing in no time. A few stumbling blocks were related to <a href="http://www.anujvarma.com/installing-and-configuring-coldfusion-with-iis7/">IIS</a> 7 (and IIS 8) and <a href="http://www.anujvarma.com/cold-fusion-administratorunable-to-browse-the-server/">adding datasources</a> to ColdFusion Server. Once those are overcome, I was all set to do CFML development on my local box. </p>
<p>NOTE: If you are just looking for a free HTML and CSS editor (without CFML support), take a look at <a href="http://kompozer.net/">KompoZer</a> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/first-pagea-free-editor-for-cold-fusion-and-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft abandoning its brightest idea ( in a long time&#8230;.)&#8211;The upcoming death of Silverlight</title>
		<link>http://www.anujvarma.com/microsoft-abandoning-its-brightest-idea-in-a-long-time-the-upcoming-death-of-silverlight/</link>
		<comments>http://www.anujvarma.com/microsoft-abandoning-its-brightest-idea-in-a-long-time-the-upcoming-death-of-silverlight/#comments</comments>
		<pubDate>Sat, 09 Mar 2013 20:06:24 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[abandon]]></category>
		<category><![CDATA[discontinue]]></category>
		<category><![CDATA[flash versus silverlight]]></category>
		<category><![CDATA[flash vs silverlight]]></category>
		<category><![CDATA[html vs silverlight]]></category>
		<category><![CDATA[html5 versus silverlight]]></category>
		<category><![CDATA[html5 vs. silverlight]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[silverlight future]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1327</guid>
		<description><![CDATA[Microsoft seems to have come up with one of the greatest technologies of recent times. A technology that would change the way websites looked and performed. Far more powerful than HTML5 or Flash.&#160; With capabilities that HTML5 can only dream &#8230; <a href="http://www.anujvarma.com/microsoft-abandoning-its-brightest-idea-in-a-long-time-the-upcoming-death-of-silverlight/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><font face="Verdana">Microsoft seems to have come up with one of the greatest technologies of recent times. A technology that would change the way websites looked and performed. Far more powerful than HTML5 or Flash.&nbsp; With capabilities that HTML5 can only dream of coming close to (without years and years of additional toolkit development). </font></p>
<p><font face="Verdana">What does a technology leader do when they come up with the idea of the decade? One that would revolutionize the way people develop web applications? </font></p>
<p><em><a href="http://www.zdnet.com/blog/microsoft/will-there-be-a-silverlight-6-and-does-it-matter/11180"><font face="Verdana">Abandon it of course.</font></a></em><font face="Verdana"> Get disheartened by the adoption of a competitive product (HTML5) or an existing product (Adobe Flash).&nbsp; Consider their idea – ‘not worth it’ or ‘a long shot’. Except that it wasn’t. Not only was (is) Silverlight way more advanced (and richer in capabilities) than HTML5 and Flash, it is richer without requiring intensive lines of code.&nbsp; This post will try and explain (to Microsoft – who shouldn’t need explaining to), why Silverlight support is sorely needed.</font></p>
<p><font face="Verdana">Microsoft has been accused of lagging – rather than leading revolutions (especially when it comes to web technologies). Internet Explorer appeared way too late and&nbsp; (after 10 releases) is still not even in the top 3 browsers in terms of performance and usability (Chrome, Firefox and Safari win over it in all metrics – memory footprint, speed of page loads, search shortcuts etc.)</font></p>
<p><font face="Verdana">For once, they actually were set to be the leader in something. And something big. Something that would change the way websites looked and felt for the next decade. What is possible to build with a Silverlight website is the stuff of dreams. </font></p>
<h3><font face="Verdana">HTML5 versus Silverlight </font></h3>
<p><font face="Verdana">I would like to see HTML5 come close to the full runtime capabilities of the .net platform ( which is what the silverlight plugin provides ). Multithreading, asynchronous page loads ( and web service calls), http and non-http bindings to external services &#8211; all with a few lines of code and some configuration files. I&#8217;m not even going to touch on the streaming capabilities of silverlight or the auto resizing , auto scaling, auto aligning &#8211; features of Silverlight controls. Try building an HTML5 app with controls that correctly resize as you switch from single to dual monitors.<br />Yes -with proper toolkits, possibly HTML5 will do some of those things in the future. Silverlight already does. It&#8217;s like having all the requisite toolkits in one, very small footprint browser plugin.<br /></font></p>
<h3><font face="Verdana">Adobe Flash versus Silverlight</font></h3>
<p><font face="Verdana">Flash is the current industry leader in rich content browser plugins. Their platform does take web development to a new level. Which is why the entire world jumped on to it. Flash changed the way websites looked after years of boring HTML pages. </font></p>
<p><font face="Verdana">Silverlight was all set to do the same thing. Take web look and feel to a whole new level. But more than look and feel, it would do something that Flash could not come even close to. By including all the runtime capabilities of (the already mature) .NET platform, Silverlight would offer unprecedented coding possibilities for web applications. Things that were hitherto difficult (if not impossible to do) – would all be available out of the box to Silverlight programmers. Asynchronous web page capabilities, multi threading – allowing for super responsive UI controls,&nbsp; WCF capabilities of talking to any type of external service – whether WS* compliant or not – whether HTTP based or not. All of this with the least amount of lines of code – and some configuration files. </font></p>
<p><font face="Verdana">To build an equally capable website in Flash would require far more code – and would still not have all the capabilities that are built into Silverlight.</font></p>
<h3><font face="Verdana">Prototyping</font></h3>
<p><font face="Verdana">Expression Blend and SketchFlow offered a super interactive (and awesome looking) prototyping experience. Not only could a developer throw together a web page’s interaction (button clicks, menu navigation etc.) quickly, a customer could interact with the exact same prototype and add his/her comments and feedback. All this in real-time. And all with super-model good looking web controls. Perhaps the greatest advantage to prototyping with these tools is that one can actually use most of the prototype screens to begin development. Unlike most prototyping tools, SketchFlow uses actual WPF and Silverlight controls. While Microsoft has still not officially abandoned these tools, they seem to be offering ‘works on this OS and this type of product only’ releases. Expression Blend&nbsp; can only be used to Windows 8 store apps. Once again, these are no ordinary tools – they would have marked a new era in prototyping tools – with super look and feel – as well as unsurpassed user-interaction capabilities. One can only hope that these tools are not completely abandoned by Microsoft.</font></p>
<h3><font face="Verdana">Summary</font></h3>
<p><font face="Verdana">I am too bummed out to write a conclusion on the death of Silverlight. Microsoft is clearly showing signs of brain fog (skewed, cloudy decision making). First, with the </font><a href="http://www.anujvarma.com/microsofts-purchase-of-skype-and-what-it-may-mean-for-the-j2ee-versus-net-battle-2-2/"><font face="Verdana">purchase of SKYPE</font></a><font face="Verdana"> (all they got for $8 billion was an additional installation screen asking if you would like to install skype on your windows box).&nbsp; If they continue to forge ahead with Silverlight (it is already a mature, fully developed platform), the simplest worst-case 2-year scenario would still have people craving for Silverlight websites – once they had an idea of what was possible. </font></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/microsoft-abandoning-its-brightest-idea-in-a-long-time-the-upcoming-death-of-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook&#8211; Essential Missing Functionality</title>
		<link>http://www.anujvarma.com/facebook-essential-missing-functionality/</link>
		<comments>http://www.anujvarma.com/facebook-essential-missing-functionality/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 01:28:40 +0000</pubDate>
		<dc:creator>Anuj Varma</dc:creator>
				<category><![CDATA[Windows Quirks, Email, Internet Gotchas]]></category>
		<category><![CDATA[edit status FB]]></category>
		<category><![CDATA[facebook edit status]]></category>
		<category><![CDATA[facebook missing functionality]]></category>
		<category><![CDATA[FB send button]]></category>

		<guid isPermaLink="false">http://www.anujvarma.com/?p=1324</guid>
		<description><![CDATA[For the world’s leading social networking site, these missing features are inexcusable:

Unable to edit status updates (there&#8217;s a trick that can be used on updates containing images &#8211; but not on regular, non-image updates).
&#8216;Send&#8217; button (e.g. while messaging someone) &#8211; &#8230; <a href="http://www.anujvarma.com/facebook-essential-missing-functionality/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For the world’s leading social networking site, these missing features are inexcusable:</p>
<ol>
<li>Unable to edit status updates (there&#8217;s a <a href="http://todmaffin.com/editupdates">trick</a> that can be used on updates containing images &#8211; but not on regular, non-image updates).</li>
<li>&#8216;Send&#8217; button (e.g. while messaging someone) &#8211; is not keyboard accessible (there is no key you can press to &#8216;Send&#8217; the message. No &#8216;Enter&#8217;, Shift Enter etc. Nothing.<br />That&#8217;s pretty primitive. It is only &#8216;mouse clickable&#8217;. A lot of users cannot use mice (RSI injuries etc.) &#8211; what are they to do?</li>
</ol>
<p>I’d like to keep updating this list – let me know of your gripe ( s ) with FB functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anujvarma.com/facebook-essential-missing-functionality/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
