<?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>Udooz!</title>
	<atom:link href="http://udooz.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://udooz.net/blog</link>
	<description>ALL ABOUT TECHNOLOGY AS I AM LEARNING WHILE DESIGNING AND DEVELOPING</description>
	<lastBuildDate>Mon, 09 Aug 2010 16:53:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>.NET DLR: Will die?</title>
		<link>http://udooz.net/blog/2010/08/net-dlr-will-die/</link>
		<comments>http://udooz.net/blog/2010/08/net-dlr-will-die/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 16:52:32 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[DLR]]></category>
		<category><![CDATA[iron ruby]]></category>
		<category><![CDATA[jimmy]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=235</guid>
		<description><![CDATA[Though my main stream is on C#, I personally like Ruby.  I was quite surprised that Microsoft started focusing on non-C family languages, those are actually coming from *nix world.  Couple of years back when Microsoft released the notes about Dynamic Language Runtime which is something like Java implementation languages like JRuby, Scala.  DLR has been scoped to [...]]]></description>
			<content:encoded><![CDATA[<p>Though my main stream is on C#, I personally like Ruby.  I was quite surprised that Microsoft started focusing on non-C family languages, those are actually coming from *nix world.  Couple of years back when Microsoft released the notes about Dynamic Language Runtime which is something like Java implementation languages like JRuby, Scala.  DLR has been scoped to be part of &#8220;lightweight&#8221; language runtime even in Silverlight.  This was surprised me.</p>
<p>I was very happy when DLR would be the carrier for domain specific language (DSL).  But, why did the general purpose languages like Ruby and Python are added as DLR in the .NET sandwich?  Wouldn&#8217;t be like C#, VB.NET or F#?  Not sure, but I was planned to use DLR for one of my custom language implementation using ANTLR.</p>
<p>Today I heared the news that Jimmy, the core developer of IronRuby was resigned from Microsoft.  The one and only one reason is Microsoft does not want to encourage these languages in the .NET world.  Jimmy wrote reasons about this (<a href="http://blog.jimmy.schementi.com/2010/08/start-spreading-news-future-of-jimmy.html" target="_blank">http://blog.jimmy.schementi.com/2010/08/start-spreading-news-future-of-jimmy.html</a>).</p>
<p>Not sure about Microsoft&#8217;s roadmap.  Would it move IronRuby from DLR stack to CLR stack?  What would be the feature and scope of DLR?  Will it be another LINQ to SQL initiative?</p>
<div style="float:left;margin:12px;" ><script type="text/javascript"><!--
google_ad_client = "pub-1206499418090878";
/* 234x60, created 4/28/09 */
google_ad_slot = "2185336927";
google_ad_width = 234;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/08/net-dlr-will-die/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which Mobile Platform&#8230;as a developer?</title>
		<link>http://udooz.net/blog/2010/07/which-mobile-platform-as-a-developer/</link>
		<comments>http://udooz.net/blog/2010/07/which-mobile-platform-as-a-developer/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 17:41:08 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=232</guid>
		<description><![CDATA[This is the million dollar question in the developer world.  Definitely mobile is the next big focus which will replace our laptop/desktop sooner.  So, only servers and gadgets will be there in future.
But as a developer, which one is best&#8230;.better&#8230;.or right platform to learn and develop.  If you think, Android or Apple iOS4&#8230;you may be wrong, [...]]]></description>
			<content:encoded><![CDATA[<p>This is the million dollar question in the developer world.  Definitely mobile is the next big focus which will replace our laptop/desktop sooner.  So, only servers and gadgets will be there in future.</p>
<p>But as a developer, which one is best&#8230;.better&#8230;.or right platform to learn and develop.  If you think, Android or Apple iOS4&#8230;you may be wrong, what about Windows Mobile&#8230;not sure until Windows Phone 7 will arrive.   A couple of years before Intel launched Moblin based on Linux but later it was merged with Nokia&#8217;s Maemo result MeeGo.  However, if you see the Q1 market share of these, do you know who is still dominating the market&#8230;.Symbian (44%).  The Apple owns 15% followed by Android with 10%.  However, the trends are in reverse, Apple and Android are rocking.</p>
<p>Oh&#8230;then on what basis one can choose the right platform to bring his dream mobile application to the world!  Of course, with quick productivity with rich framework and tools (like Visual Studio &amp; .NET or Ruby on Rails).  What will happened to my rich-web application?  Still, am I kept in touch with ASP.NET, PHP, RoR?</p>
<p>On the other side, Qt4 and J2ME look promising in &#8220;one skillset on multiple appliances&#8221;.</p>
<p>If you are in .NET world, Windows Phone 7 might be&#8230;.but have to wait this yera fall.  MonoTouch is bonus for iPhone world. Java&#8230;.stick with J2ME&#8230;sooner Android.  Not sure about iPhone.</p>
<p>Anyhow, be ready to work with at least three skill sets.</p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/07/which-mobile-platform-as-a-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu&#8217;s Lucid: More Humanity</title>
		<link>http://udooz.net/blog/2010/05/ubuntus-lucid-more-humanity/</link>
		<comments>http://udooz.net/blog/2010/05/ubuntus-lucid-more-humanity/#comments</comments>
		<pubDate>Sun, 23 May 2010 07:12:42 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=230</guid>
		<description><![CDATA[As a fan of Ubuntu for last three years, awaiting its version 10.4, for its LTS (long term support) mode which in turn gives surprising features makes me more humanize:
Social integrated within the system using Gwibber so that we can enjoy twitter, face book natively.
Booting is boosted with some major tweaks for example HAL has [...]]]></description>
			<content:encoded><![CDATA[<p>As a fan of Ubuntu for last three years, awaiting its version 10.4, for its LTS (long term support) mode which in turn gives surprising features makes me more humanize:</p>
<p>Social integrated within the system using Gwibber so that we can enjoy twitter, face book natively.</p>
<p>Booting is boosted with some major tweaks for example HAL has been removed during the booting.</p>
<p>Though this is far from Windows 7, I like it along with Win 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/05/ubuntus-lucid-more-humanity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beware of SCA if you are in WCF</title>
		<link>http://udooz.net/blog/2010/03/beware-of-sca-if-you-are-wcf/</link>
		<comments>http://udooz.net/blog/2010/03/beware-of-sca-if-you-are-wcf/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 19:45:34 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[SCA]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=223</guid>
		<description><![CDATA[Today, a technology newsletter carried with an article about SCA (Service Component Architecture) which is outshone at IBM campus along with BEA.  Is it a another SOA specification?  Is it a SOA framework? or, alternate to SOA?  Michael Rowley who is the author/architect/inventor of this said that it depends.  Confused.  Yes, it has been mentioned that SOA [...]]]></description>
			<content:encoded><![CDATA[<p>Today, a technology newsletter carried with an article about SCA (Service Component Architecture) which is outshone at IBM campus along with BEA.  Is it a another SOA specification?  Is it a SOA framework? or, alternate to SOA?  Michael Rowley who is the author/architect/inventor of this said that it depends.  Confused.  Yes, it has been mentioned that SOA is hyped much and many of the things are futile.</p>
<h2>Concept behind SCA</h2>
<p>Following are the key aspects of SCA:</p>
<ul>
<li>Services &#8211; a set of operations that perform logically related tasks</li>
<li>Components &#8211; contains the implementation and configuration of services</li>
<li>Composites &#8211; responsible for configuring services</li>
<li>Domain &#8211; A physical environment where the components will be hosted for consumption</li>
</ul>
<p>A service contains a service contract and address.  Service contract specifies the operations available in the service, the inputs for which to operate and the promised outputs.  Service address provides where the service contract is available for consumption.  Components is nothing but C++ libraries or Java JARs.  Composites are XML file which contains the map between service contract and its implementation.  The domain enables to manage the components and apply policies for their access.  It provides common communication infrastructure and extensibility stuffs.</p>
<h2>Technology behind SCA</h2>
<p>Although in the specification it has been mentioned that SCA is technology and language independant, it is majorly on Java.  It has been mentioned that SCA is a concept as well as a framework but does not contains anything for presentation layer and data persistence.  However, it integrates with Java based UI and DB framworks.</p>
<h2>So&#8230;What?</h2>
<p>Instead of web services, SCA lets you connect and composite through web services, RPC or anyother means, unlike today protocol based SOA approach.   This is what mentioned and marketed in the SCA specification.  When you are crossing the border of &#8220;Concept behind SCA&#8221; section of this post, you have surprised that what is new in SCA for SOA, since WCF  incorporated these few years back when this specification was only on the paper.  More interesting and confusing thing is the specification team invited Microsoft for adopting this into .NET.  One more buzz is that this specification is based on WSDL.  These two make me what else have been proposed apart from what WCF has now with such the level of maturity.</p>
<blockquote><p>For those who want clear map between above concepts and WCF:</p>
<ul>
<li>Services - C# interface with WCF declarations</li>
<li>Components &#8211; C# classes with WCF declarations</li>
<li>Composites &#8211; Service model section in app.config/web.config file.</li>
<li>Domain &#8211; Service host (IIS/WAS/Windows Process)</li>
</ul>
</blockquote>
<h2>What does it has&#8230;.What doesn&#8217;t?</h2>
<p>It provides the following:</p>
<ul>
<li>Service reference &#8211; dependency with other services</li>
<li>Composition &#8211; way to encapsulate technical/vertical components such as validation, logging and auditing components within service and hide these to the outworld.</li>
<li>Policy - a statement that controls the operations that provided by the infrastructure.</li>
<li>Wire &#8211; a way for service aggregation and topologies (oneway, duplex, request and response)</li>
<li>Bindings &#8211; provides the means to communicate to the consumers.</li>
</ul>
<p>It doesn&#8217;t have the following:</p>
<ul>
<li>Service orchestration &#8211; but supports JSR based on BPEL</li>
<li>Service extension</li>
<li>Service inventory</li>
</ul>
<p>Unfortunately, WCF has all the above with the power of .NET platform.  So, beware of SCA jargon in .NET world, where an elephant WCF has all the capabilities.  As of my understanding, SCA is WCF avatar in Java world.</p>
<p>Michael Rowley saluted the WCF proposals and its features, however he tried to oversight it with SCA.  Its confused.<br />
<a style="display: none;" rel="tag" href=" http://udooz.net/blog/2010/03/beware-of-sca-if-you-are-wcf/">CodeProject</a></p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/03/beware-of-sca-if-you-are-wcf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IIS 7.0 and WAS : A Primer</title>
		<link>http://udooz.net/blog/2010/03/iis-7-0-and-was-a-primer/</link>
		<comments>http://udooz.net/blog/2010/03/iis-7-0-and-was-a-primer/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 01:39:55 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[AppFabric]]></category>
		<category><![CDATA[HTTP.sys]]></category>
		<category><![CDATA[IIS 7.0]]></category>
		<category><![CDATA[W3SVC]]></category>
		<category><![CDATA[W3WP]]></category>
		<category><![CDATA[WAS]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=216</guid>
		<description><![CDATA[Continue to my previous introductory post about AppFabric, it is very fundamental to know the architecture IIS 7.0 and WAS.  So, this post.

In the above diagram, you can see two regions in Windows. The kernal mode and user mode, and you know that processes in the kernal mode touches the CPU and other hardwares without any [...]]]></description>
			<content:encoded><![CDATA[<p>Continue to my previous <a href="http://udooz.net/blog/2010/03/appfabric-overview/" target="_self">introductory post about AppFabric</a>, it is very fundamental to know the architecture IIS 7.0 and WAS.  So, this post.</p>
<p><img class="alignnone size-full wp-image-218" style="border: black 1px solid;" title="IIS 7.0 Architecture" src="http://udooz.net/blog/wp-content/uploads/2010/03/IIS7_1.png" alt="IIS 7.0 Architecture" width="469" height="600" /></p>
<p>In the above diagram, you can see two regions in Windows. The kernal mode and user mode, and you know that processes in the kernal mode touches the CPU and other hardwares without any interface and have the rights to access physical memory without any virtual address mapping. The user mode processes are our own applications along with Windowing Subsystem which also includes Windows Network Subsystem.  Processes in the user mode requires processes in the kernal mode such as thread scheduling, memory, cache or IO related activities. So, it would require a thread <em>context switching</em> means that kernal model thread has been created and the data in the user mode thread has been transferred into kernal mode thread.  Ahhh, I&#8217;m explaining too much about Windows processing.  Lets cut off.</p>
<h2>IIS 7 Components</h2>
<h3>Application Pool and Worker Process</h3>
<p>Worker process is a windows process which is specifically designed for hosting and running static, ASP or ASP.NET web applications in IIS.  w3wp.exe is responsible for loading the appropriate ISAPI (a lower level programming module for handling specific web application, for example aspnet_isapi.dll for ASP.NET) filters and starts a new worker process for a request.</p>
<p>Application pool is a grouping of web applications those are routed to one or more worker processes.  Processes in one application pool will not be impacted by another application pool&#8217;s failure.</p>
<h3>Request Processing Pipeline and Modules</h3>
<p>A request processing pipeline is created for every request.  In the previous versions of IIS, if a request is for ASP.NET application, the application needs to exit from the IIS pipeline and load aspnet_isapi for handling ASP.NET code which inturn creates its own request processing pipeline.  In II7, both IIS and ASP.NET request pipelines are combined and called as &#8220;<strong>Integrated Pipeline</strong>&#8220;.  This pipeline contains one or more modules.  Module is a component which contain a specific set of features for IIS to handle a request.  For example, BasicAuthenticationModule is a module for performing basic authentication and FileCacheModule is a module for caching files and file handles.</p>
<p>The integrated pipeline has following benefits:</p>
<ul>
<li>Eliminating the duplication of features between IIS and ASP.NET, for example authentication</li>
<li>One inventory for all IIS modules</li>
<li>Performance&#8230;performance&#8230;</li>
</ul>
<p><strong>WWW Service and WAS</strong></p>
<p>It is necessary that a dedicated component is required for listening for requests and managing application pools and worker processes.  In IIS 7, WAS (Windows Process Activation Service) is dedicated for this.  Requests coming from different transports like HTTP, TCP/IP, NetPipe and MSMQ are handled by respective listener adapters configured in the WAS.  When a request is coming which is directed to respective listerner adapters which passes the request to appropriate worker process, where the application manager directs the request to the specific application.</p>
<p>WWW Service (World wide web publishing service, simply w3svc) is the listener adapter for HTTP.  Apart from this, it manages the configuration stuffs required for HTTP related.</p>
<h3>Protocol Listeners and HTTP.sys (Kernal Mode)</h3>
<p>As its name reflects, protocols listeners receive appropriate requests and passes them to the IIS.  Note that protocol listener are kernal mode processes.  This model allows to handle any protocol, and the only thing we require is appropriate device drive as like as HTTP.sys for HTTP requests.</p>
<p>Whenever a HTTP request is entering into the server, HTTP.sys receives the requests and pass it to appropriate worker process if exists, otherwise it puts the request in the request queue.  When a response for a request is already in the response cache, it fetches that and reply it back without noticing and invoking worker process.</p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/03/iis-7-0-and-was-a-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Server AppFabric &#8211; 10K ft View</title>
		<link>http://udooz.net/blog/2010/03/appfabric-overview/</link>
		<comments>http://udooz.net/blog/2010/03/appfabric-overview/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 04:33:38 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[appfabric]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=211</guid>
		<description><![CDATA[After a quite while, I&#8217;d a chance to start looking into Windows Server AppFabric.  This is one my long pending middler tier component from Windows/.NET combo.
What is AppFabric?
A set of components provide service hosting, in-memory caching, stateful services persistence and management services, management consoles and API to access these services.  The following figure shows the major responsibilities of AppFabric components.

Hosting [...]]]></description>
			<content:encoded><![CDATA[<p>After a quite while, I&#8217;d a chance to start looking into Windows Server AppFabric.  This is one my long pending middler tier component from Windows/.NET combo.</p>
<h2>What is AppFabric?</h2>
<p>A set of components provide service hosting, in-memory caching, stateful services persistence and management services, management consoles and API to access these services.  The following figure shows the major responsibilities of AppFabric components.</p>
<p><a href="http://udooz.net/blog/wp-content/uploads/2010/03/AppFabric1.png"><img class="alignnone size-full wp-image-212" style="border: black 1px solid;" title="AppFabric1" src="http://udooz.net/blog/wp-content/uploads/2010/03/AppFabric1.png" alt="AppFabric components responsibilities" width="404" height="178" /></a></p>
<p>Hosting services extends WAS (Windows Process Activation Service) with some default configuration, workflow management and, administration tools.  In-memory caching, previously code-named as Velocity, is a solution for scalable caching of enterprise/web applications.  Its cluster architecture and provision to configure various caching options enable us to prepare feast for small to large crowd.  Not know in detail about what makes different from WF 3.x and SQL Server combo, and state persistence service in AppFabric.  Let us see in detail on future logs.  To manage these aspects, AppFabric provides variety of management services which includes dashboard, service deployment, monitors and APIs.</p>
<h2>Setup your AppFabric Environment</h2>
<p>Windows Server AppFabric is actually designed for Windows 2008, but has development stage avatars for Windows Vista/7.  AppFabric beta 1 targetedc .NET 4.0 beta 2 and AppFabric beta 2 is targeted .NET 4.0 RC.  It will act as extension of IIS 7.0.  The following figure shows the IIS MMC for this.</p>
<p><a href="http://udooz.net/blog/wp-content/uploads/2010/03/AppFabric2.png"><img class="alignnone size-full wp-image-214" title="IIS MMC for App Fabric" src="http://udooz.net/blog/wp-content/uploads/2010/03/AppFabric2.png" alt="" width="530" height="379" /></a></p>
<p>The Windows 7/2008 beta 1 can be downloaded at <a href="http://download.microsoft.com/download/0/A/E/0AEB3BC1-506E-4954-8AB1-4FA2EE75985C/AseSetup_x86_6.1.exe" target="_blank">http://download.microsoft.com/download/0/A/E/0AEB3BC1-506E-4954-8AB1-4FA2EE75985C/AseSetup_x86_6.1.exe</a>.</p>
<p>Beta 2 can be downloaded at <a href="http://download.microsoft.com/download/F/D/4/FD4F05A5-016B-40F8-A61F-1D38E202A32A/WindowsServerAppFabricSetup_x86_6.1.exe" target="_blank">http://download.microsoft.com/download/F/D/4/FD4F05A5-016B-40F8-A61F-1D38E202A32A/WindowsServerAppFabricSetup_x86_6.1.exe</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/03/appfabric-overview/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# 4.0 Crash Course: Optional and Named Parameter</title>
		<link>http://udooz.net/blog/2010/02/c-4-0-crash-course-optional-and-named-parameter/</link>
		<comments>http://udooz.net/blog/2010/02/c-4-0-crash-course-optional-and-named-parameter/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:08:13 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#4.0]]></category>
		<category><![CDATA[course]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[optional]]></category>
		<category><![CDATA[parameter]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=203</guid>
		<description><![CDATA[Parameters with default value. Hence, explicit values not specified in the calling place, default value has been taken.

static void Power(int v, int p = 2)
{
 Console.WriteLine(&#34;{0} Power of {1} = {2}&#34;, v, p, Math.Pow(v, p));
}

p is the optional parameter here. By default Power does calculate square of v, if p value provided explicitly, does calculate [...]]]></description>
			<content:encoded><![CDATA[<p>Parameters with default value. Hence, explicit values not specified in the calling place, default value has been taken.</p>
<pre class="brush: csharp;">
static void Power(int v, int p = 2)
{
 Console.WriteLine(&quot;{0} Power of {1} = {2}&quot;, v, p, Math.Pow(v, p));
}
</pre>
<p><span style="color: #800080;">p</span> is the optional parameter here. By default <span style="color: #800080;">Power</span> does calculate square of <span style="color: #800080;">v</span>, if <span style="color: #800080;">p</span> value provided explicitly, does calculate <span style="color: #800080;">v</span> to the power of <span style="color: #800080;">p</span>.</p>
<pre class="brush: csharp;">
Power(2, 3);  // 2 ** 3 = 8
Power(4); // 4 ** 2 = 16
</pre>
<p>Actually, two parameter target attributes help to make this feature available. These are:</p>
<ul>
<li><span style="color: #800080;">OptionalAttribute</span></li>
<li><span style="color: #800080;">DefaultParameterValueAttribute</span></li>
</ul>
<p>in <span style="color: #800080;">System.Runtime.InteropServices</span> namespace.</p>
<p>The OptionalAttribute marks the parameter as optional as like</p>
<pre class="brush: csharp;">

static void Power(int v, [Optional] p) {...} // p's default value is to default(int) i.e. 0

Power(5); // prints 1
</pre>
<p>The DefaultParameterValueAttribute constructor takes value parameter of type object is used to initialize the default value of the target parameter.</p>
<pre class="brush: csharp;">

static void Power(int v, [Optional][DefaultParameterValue(2)] p) {...} // p's default value is 2
</pre>
<p>Points to be noted on &#8220;optional&#8221; parameter usage:</p>
<ul>
<li>Optional parameter should be the last parameter as like &#8220;param&#8221; usage</li>
<p>ref and <span style="color: #800080;">out</span> parameters.</ul>
<h2>Named Parameters</h2>
<p>Optional parameter will not be useful in real without named parameters. Yes, the name itself tells the answer. What will you do if you have more than one optional parameters and at the calling place, you want to pass actual value for less number of optional parameters. For example</p>
<pre class="brush: csharp;">

static void MoreOptionalParamMethod(int a = 0, int b = 1, int c = 2)
{
 Console.WriteLine(&quot;a= {0}, b= {1}, c= {2}, &quot;, a, b, c);
}
</pre>
<p>Now, you want to pass the value of variable b only. Named parameter will help you.</p>
<blockquote><p>Instead of parameter order, you can explictly specify parameter name along with the value using &#8220;:&#8221; in the calling place</p></blockquote>
<p>See the following calling place</p>
<pre class="brush: csharp;">
MoreOptionalParamMethod(b: 5); // prints a= 0, b= 5, c= 2
</pre>
<p>There is no surprising in the IL code, the compiler replaces optional parameters with default values as like below</p>
<pre class="brush: csharp;">
MoreOptionalParamMethod(0, 5, 2);
</pre>
<p>The only thing to be considered is named and normal parameters can be mixed but normal parameter should be come first.</p>
<p><a style="display: none;" rel="tag" href="http://www.codeproject.com/script/Articles/BlogFeedList.aspx?amid=3057856">CodeProject</a></p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/02/c-4-0-crash-course-optional-and-named-parameter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET Caching Solutions &#8211; A Pre-Velocity Review</title>
		<link>http://udooz.net/blog/2010/01/net-caching-solutions-review/</link>
		<comments>http://udooz.net/blog/2010/01/net-caching-solutions-review/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 04:17:38 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CAB]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Enterprise Library]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[NCache]]></category>
		<category><![CDATA[Shared Cache]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=198</guid>
		<description><![CDATA[Caching is one of the vital aspect for enterprise applications.  ASP.NET Cache is not enough and even not suitable for service layer which is now more predominantly occupied by WCF. A robustic and scalable memory caching solution is required to cache different types of data.  I&#8217;m the beliver of &#8220;RAM is disk&#8221; for service layer.  [...]]]></description>
			<content:encoded><![CDATA[<p>Caching is one of the vital aspect for enterprise applications.  ASP.NET Cache is not enough and even not suitable for service layer which is now more predominantly occupied by WCF. A robustic and scalable memory caching solution is required to cache different types of data.  I&#8217;m the beliver of &#8220;<strong>RAM is disk</strong>&#8221; for service layer.  <a href="http://msdn.microsoft.com/en-us/library/dd203226.aspx" target="_blank">Enterprise Library Caching Application Block (CAB)</a> from Microsoft PnP team provides an in-process memory caching, however it is not scalable and robust. But, its provider pattern is an elegant model for application design, so that you can plug any caching solutions.</p>
<p>Recently, I was in a situation to find out suitable caching solution for our WCF based service layer.  Although, Microsoft yet to avail its &#8220;Windows Server AppFabric&#8221; to the .NET/WCF world (which might be the filler of .NET peoples&#8217; decade old expectation), there are some caching solutions available from third parties. </p>
<p>I did a small evaluation on the following caching solutions:</p>
<ul>
<li>NCache Express</li>
<li>Shared Cache</li>
<li>Memcached</li>
<li>Enterprise Library 4.1</li>
</ul>
<blockquote><p>Disclaimer: The test was done at very small scale and not included the scalability factors.  Memory and CPU consumption were not covered.</p></blockquote>
<p><a href="http://www.alachisoft.com/ncache/" target="_blank">NCache</a> supports different caching topologies and types with many features like Object Query Language, remote clustering, etc.  I&#8217;ve taken its express edition for this evaulation.  <a href="http://www.sharedcache.com/cms/" target="_blank">Shared Cache</a> is 100% written in C# with distributed caching and three different topologies.  It supports WCF DataContractSerializer in addition with BinarySerializer.  Guys from *nux world knows the defacto caching solution &#8220;<a href="http://memcached.org/" target="_blank">memcached</a>&#8220;.  It has Win32/64 avatar too and some open source managed client libraries also available.  I used Danga Interactive 32-bit version of memcached 1.2.6 (<a href="http://code.jellycan.com/memcached/" target="_blank">http://code.jellycan.com/memcached/</a>) and BeIT Memcached managed client (<a href="http://code.google.com/p/beitmemcached/" target="_blank">http://code.google.com/p/beitmemcached/</a>).  64-bit Windows version is available at <a href="http://labs.northscale.com/memcached-packages/" target="_blank">http://labs.northscale.com/memcached-packages/</a>.</p>
<p>I&#8217;d done a small performance testing on the above solutions.  In addition to these, I&#8217;ve used Enterprise Library 4.1 CAB provider model and implement provider for these solutions.  So, following different solutions had been tested:</p>
<ul>
<li>Enterprise Library 4.1 CAB</li>
<li>Memcached</li>
<li>Enterprise Library 4.1 based Memcached</li>
<li>Shared Cache</li>
<li>Enterprise Library 4.1 based Shared Cache</li>
<li>NCache Express</li>
<li>Enterprise Library 4.1 based NCache Express</li>
</ul>
<p>Following three different test had been done on every solutions, totally 21 test:</p>
<ul>
<li>Adding 1000 items &amp; Getting these items</li>
<li>Adding 1000 items &amp; Getting 5th element</li>
<li>Adding 1000 items &amp; Getting 995th element</li>
</ul>
<p>The testing was performed on Intel Pentium 4 3.2GHz, 2GB RAM running WinXP SP2.</p>
<p>Let us see the results and, pros and cons of these solutions.</p>
<h2>Enterprise Library 4.1</h2>
<p>Not surprisingly excellent performance due to in-process memory caching, however not suitable for enterprise scale.  This supports primitive and Serializable objects.</p>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>EntLib 4.1</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td style="TEXT-ALIGN: center">R1</td>
<td style="TEXT-ALIGN: center">R2</td>
<td style="TEXT-ALIGN: center">R3</td>
<td style="TEXT-ALIGN: center">R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">21</td>
<td align="right">13</td>
<td align="right">23</td>
<td align="right">12</td>
<td align="right">17.25</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">9</td>
<td align="right">5</td>
<td align="right">9</td>
<td align="right">5</td>
<td align="right">7</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">4</td>
<td align="right">3</td>
<td align="right">3</td>
<td align="right">2</td>
<td align="right">3</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">4</td>
<td align="right">3</td>
<td align="right">3</td>
<td align="right">2</td>
<td align="right">3</td>
</tr>
</tbody>
</table>
<p>The &#8220;R&#8221; deonotes &#8220;Run&#8221;.  I did 4 runs for every test.</p>
<h2>Memcached</h2>
<p>Since, the OS calls for *nux memcached and Windows memcached is different, some bloggers cautioned memcached on windows is might not be a win-win.  But, I could not find any degrades in my testing.  It takes small memory foot-print and CPU usage.  It supports primitive and Serializable objects.  However, the Win32 service version does not have flexible configuration.</p>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>MemCached</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td>R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">166</td>
<td align="right">160</td>
<td align="right">203</td>
<td align="right">164</td>
<td align="right">173.25</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">154</td>
<td align="right">140</td>
<td align="right">175</td>
<td align="right">138</td>
<td align="right">151.75</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
<td align="right">5</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>EntLib MemCached</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td>R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">178</td>
<td align="right">164</td>
<td align="right">202</td>
<td align="right">193</td>
<td align="right">184.25</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">5</td>
<td align="right">3</td>
<td align="right">6</td>
<td align="right">3</td>
<td align="right">4.25</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">2</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.5</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">2</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.5</td>
</tr>
</tbody>
</table>
<h2>Shared Cache</h2>
<p>Like Enterprise Library 4.1 CAB, this solution uses provider like model and come out with IndexusDistributionCache which supports WCF data contract serializer too in addition with binary serializer.</p>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>SharedCache</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td>R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">4723</td>
<td align="right">3441</td>
<td align="right">3904</td>
<td align="right">3592</td>
<td align="right">3915</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">3357</td>
<td align="right">3633</td>
<td align="right">4582</td>
<td align="right">3722</td>
<td align="right">3823.5</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">12</td>
<td align="right">14</td>
<td align="right">17</td>
<td align="right">13</td>
<td align="right">14</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">13</td>
<td align="right">14</td>
<td align="right">13</td>
<td align="right">14</td>
<td align="right">13.5</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>EntLib SharedCache</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td>R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">3649</td>
<td align="right">3612</td>
<td align="right">4379</td>
<td align="right">4992</td>
<td align="right">4158</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">5</td>
<td align="right">2</td>
<td align="right">5</td>
<td align="right">3</td>
<td align="right">3.75</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">3</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.75</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">3</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.75</td>
</tr>
</tbody>
</table>
<h2>NCache</h2>
<p>This is more matured and tailored solution for .NET world.  The best is the object is not necessarily Serializable.</p>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>Ncache</strong></td>
</tr>
<tr height="20">
<td height="20"> </td>
<td>R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">365</td>
<td align="right">282</td>
<td align="right">382</td>
<td align="right">296</td>
<td align="right">331.25</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">257</td>
<td align="right">248</td>
<td align="right">287</td>
<td align="right">234</td>
<td align="right">256.5</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">12</td>
<td align="right">8</td>
<td align="right">10</td>
<td align="right">8</td>
<td align="right">9.5</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">12</td>
<td align="right">8</td>
<td align="right">8</td>
<td align="right">8</td>
<td align="right">9</td>
</tr>
</tbody>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="548">
<colgroup span="1">
<col span="1" width="228"></col>
<col span="5" width="64"></col>
</colgroup>
<tbody>
<tr height="20">
<td width="228" height="20"> </td>
<td style="TEXT-ALIGN: center" colspan="5" width="320"><strong>EntLib Ncache</strong></td>
</tr>
<tr height="20">
<td height="20">            </td>
<td>  R1</td>
<td>R2</td>
<td>R3</td>
<td>R4</td>
<td style="TEXT-ALIGN: center">Avg</td>
</tr>
<tr height="20">
<td height="20">Adding 1000 items (in ms)</td>
<td align="right">317</td>
<td align="right">277</td>
<td align="right">367</td>
<td align="right">278</td>
<td align="right">309.75</td>
</tr>
<tr height="20">
<td height="20">Getting 1000 items (in ms)</td>
<td align="right">5</td>
<td align="right">2</td>
<td align="right">5</td>
<td align="right">3</td>
<td align="right">3.75</td>
</tr>
<tr height="20">
<td height="20">Get 5th item (1000 items) (in ms)</td>
<td align="right">2</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.5</td>
</tr>
<tr height="20">
<td height="20">Get 995th item (1000 items) (in ms)</td>
<td align="right">3</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0.75</td>
</tr>
</tbody>
</table>
<p>The results shows Memcached performed better for its consistent performance and simplicity.  The surprising fact is that the above all solutions perform well in Enterprise Library 4.1 CAB provider model than their default mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2010/01/net-caching-solutions-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google GO &#8211; NOT Love @ First Sight</title>
		<link>http://udooz.net/blog/2009/11/google-go-not-love-first-sight/</link>
		<comments>http://udooz.net/blog/2009/11/google-go-not-love-first-sight/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 18:25:41 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[GO]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=192</guid>
		<description><![CDATA[Finally, Google makes its contribution apart from &#8220;www&#8221; after its yet another linux distro Google Chrome OS.  This time in language space.  Its name is &#8220;Go&#8221;.
Its released for Linux and Mac only.  After downloading the source from https://go.googlecode.com/hg, building the packages and set some environment variables (guide @ http://golang.org/doc/install.html), tried a small sample which greets [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, Google makes its contribution apart from &#8220;www&#8221; after its yet another linux distro Google Chrome OS.  This time in language space.  Its name is &#8220;Go&#8221;.</p>
<p>Its released for Linux and Mac only.  After downloading the source from <a href="http://golang.org/doc/install.html" target="_blank">https://go.googlecode.com/hg,</a> building the packages and set some environment variables (guide @ <a href="http://golang.org/doc/install.html" target="_blank">http://golang.org/doc/install.html</a>), tried a small sample which greets the arg(0) given from console.</p>
<p>The syntax is neither smart nor friendlier at my first sight.  Seems it is a mix of JavaScript, Java and ofcourse, C++.  For each and every compilation you need to specify target machine architecture, 6g &#8211; for AMD, 8g &#8211; for 386.</p>
<p>See the following sample hello, &lt;user&gt; sample:</p>
<pre class="brush: c;">

package main

import (
&quot;fmt&quot;; // formatted stdin
&quot;flag&quot;; // command line parser
)

func main(){
 flag.Parse();

 fmt.Printf(&quot;hello,&quot; + flag.Arg(0) + &quot;\n&quot;);
}
</pre>
<p>After the compilation with 8g, invoke the linker 8l and generate the executable (normally 8.out).  Since I did not evaluate this language at some level and did not read its architecture, I could not give any comments of this early stage compiler. However, at my first sight,</p>
<p><strong>GO = Neither C# Nor Ruby</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2009/11/google-go-not-love-first-sight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.NET 4.0 Work Stealing Queue, Parallel and PLINQ</title>
		<link>http://udooz.net/blog/2009/08/net-4-0-work-stealing-queue-plinq/</link>
		<comments>http://udooz.net/blog/2009/08/net-4-0-work-stealing-queue-plinq/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 17:44:54 +0000</pubDate>
		<dc:creator>udooz</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Parallel]]></category>
		<category><![CDATA[PLINQ]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[task]]></category>
		<category><![CDATA[thread pool]]></category>
		<category><![CDATA[work stealing]]></category>

		<guid isPermaLink="false">http://udooz.net/blog/?p=181</guid>
		<description><![CDATA[In my previous post, we have seen basis of Task Parallel Library, where I have mentioned new task scheduler in .NET 4.0 thread pool.  In this post I brief about it along with &#8220;Task&#8221; class.   Before this, let us see how to make LINQ as parallel using PLINQ.
PLINQ
PLINQ has implementation of  all LINQ to Objects extension methods in System.Linq.ParallelEnumerable [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://udooz.net/blog/2009/08/parallel-programming-net-4-0-using-task/" target="_self">my previous post</a>, we have seen basis of Task Parallel Library, where I have mentioned new task scheduler in .NET 4.0 thread pool.  In this post I brief about it along with &#8220;Task&#8221; class.   Before this, let us see how to make LINQ as parallel using PLINQ.</p>
<h2>PLINQ</h2>
<p>PLINQ has implementation of  all LINQ to Objects extension methods in <span style="color: #993300;">System.Linq.ParallelEnumerable </span>for <span style="color: #993300;">IEnumerable</span>.  To make an <span style="color: #993300;">IEnumerable</span> parallel, you simply call <span style="color: #993300;">AsParallel()</span> extension method.  <span style="color: #993300;">AsParallel()</span> internally calls <span style="color: #993300;">System.Linq.Parallel.ParallelEnumerableWrapper</span> which is of type <span style="color: #993300;">System.Linq.ParallelQuery&lt;TSource&gt;</span>.  Let us take the same customer-order example as shown in <a href="http://udooz.net/blog/2009/08/parallel-programming-net-4-0-using-task/" target="_self">my previous post</a> with  PLINQ enabled.</p>
<pre class="brush: csharp;">
var customersForOrderId7 =
    from c in customers.AsParallel()
    from o in c.Orders
    where o.OrderId == 7
    select c;
 

customersForOrderId7.ForAll(c =&gt;
    Console.WriteLine(c.ToString()));
</pre>
<p>The above code selects customers who have ordered OrderId 7.  <span style="color: #993300;">AsParallel()</span> at line 3 makes <span style="color: #993300;">Customer[]</span> as parallel enabled.  In this example, you can see that instead of typical <span style="color: #993300;">for&#8230;each</span>, I&#8217;ve used <span style="color: #993300;">ForAll()</span>.  This differs from <span style="color: #993300;">for..each,</span> means that for..each preservs the final order of the results.</p>
<h2>Thread Pool and Work Stealing Queue</h2>
<p>Until .NET3.5, we can queue our work items as thread in to <span style="color: #993300;">ThreadPool</span> using <span style="color: #993300;">QueueUserWorkItem()</span>.  In .NET 4.0, improvements had been made in the thread pool.  It is now based on <span style="color: #993300;">System.Threading.Tasks.Task</span>. </p>
<h3>Task</h3>
<p>Task is a work item which can be executed independently along with other tasks, technically it represents an asynchronous operation i.e. <span style="color: #993300;">System.Action</span>.  It is defined in <span style="color: #993300;">System.Threading.Tasks.Task</span> which enables you to do the following actions on a task instance:</p>
<ul>
<li>start &#8211; to start the instance</li>
<li>wait &#8211; to wait to for a task to complete</li>
<li>cancel &#8211; cancel the task asynchronously</li>
</ul>
<blockquote><p>It seems that task is a lite version of thread.</p></blockquote>
<h3>Thread Pool</h3>
<p>Following diagram shows the conceptual view of .NET 4.0 thread pool.</p>
<p><img class="alignnone size-full wp-image-185" style="margin: 2px; border: black 1px solid;" title=".NET 4.0 Thread Pool" src="http://udooz.net/blog/wp-content/uploads/2009/08/pfx_thread_pool_2.png" alt=".NET 4.0 Thread Pool" width="405" height="287" /></p>
<p>Previously, thread pool had only one queue on which all the work items were queued and enqueued in FIFO order (ofcourse, thats why queue).  The worker threads are allocated for every work item access the work item from this queue.  In .NET 4.0, it has been improved by introducing <em>local queue</em> for every worker thread, in addition to qlobal queue.  Tasks those are created by program thread queued on global queue.  The task scheduler enqueues the tasks from global queue in FIFO order and distributes to respective worker thread&#8217;s local queue.  The worker thread enqueues the tasks from its local queue in LIFO order.  Interesting!</p>
<blockquote><p>The introduction of local queue makes these threads can be executed on different processors without contention issue which normally occur in single queue thread pool.  The reason for worker thread picking up the tasks in LIFO order is the assumption that &#8220;last-in&#8221; is hot to act which results no qurantee in task ordering, but better performance.</p></blockquote>
<h3>Work Stealing Queue</h3>
<p>Let us assume that worker thread 1 completed all of its tasks in the queue.  It scans the global queue for any task and if nothing there, it scans other worker thread&#8217;s local queue.  In this case, let us assume there are two tasks in WT2 queue.  WT1 enqueues first-in task from WT2 queue which avoids contention issue.  Getting tasks from other local queue is called as <em>work stealing</em>.  This again results better performance.</p>
<h2>References</h2>
<p>MSDN article: Task Parallel Library Overview: <a href="http://msdn.microsoft.com/en-us/library/dd460717(VS.100).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/dd460717(VS.100).aspx</a></p>
<p>Daniel Moth&#8217;s videocast and PPT deck: <a href="http://channel9.msdn.com/pdc2008/TL26/" target="_blank">http://channel9.msdn.com/pdc2008/TL26/</a> and his article about thread pool at <a href="http://www.danielmoth.com/Blog/2008/11/new-and-improved-clr-4-thread-pool.html" target="_blank">http://www.danielmoth.com/Blog/2008/11/new-and-improved-clr-4-thread-pool.html</a></p>
<p>My Code sample for PLINQ as used in this post is at <a href="http://www.udooz.net/file-drive/doc_details/9-tpl-and-plinq-example.html" target="_blank">http://www.udooz.net/file-drive/doc_details/9-tpl-and-plinq-example.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://udooz.net/blog/2009/08/net-4-0-work-stealing-queue-plinq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
