<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">

<channel>
	<title>Roger Alsing Weblog</title>
	
	<link>http://rogeralsing.com</link>
	<description />
	<lastBuildDate>Sat, 18 May 2013 10:53:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain="rogeralsing.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post" />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Roger Alsing Weblog</title>
		<link>http://rogeralsing.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://rogeralsing.com/osd.xml" title="Roger Alsing Weblog" />
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RogerAlsingWeblog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="rogeralsingweblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://rogeralsing.com/?pushpress=hub" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">RogerAlsingWeblog</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>PiCloud</title>
		<link>http://rogeralsing.com/2013/01/18/picloud/</link>
		<comments>http://rogeralsing.com/2013/01/18/picloud/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 12:15:10 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1154</guid>
		<description><![CDATA[Back in 2009 I blogged about F# in the cloud, an idea where you could pass an F# AST to a cloud and run it in parallell there : http://rogeralsing.com/2009/12/29/massive-parallelism-f-in-the-cloud/ It now seems like some guys have done just that using &#8230; <a href="http://rogeralsing.com/2013/01/18/picloud/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1154&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Back in 2009 I blogged about F# in the cloud, an idea where you could pass an F# AST to a cloud and run it in parallell there :<a href="http://rogeralsing.com/2009/12/29/massive-parallelism-f-in-the-cloud/"> http://rogeralsing.com/2009/12/29/massive-parallelism-f-in-the-cloud/</a></p>
<p>It now seems like some guys have done just that using python : <a title="picloud" href="http://www.picloud.com/">http://www.picloud.com/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1154&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=60HYtvh315Y:nBIMv7uENQI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=60HYtvh315Y:nBIMv7uENQI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=60HYtvh315Y:nBIMv7uENQI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=60HYtvh315Y:nBIMv7uENQI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/60HYtvh315Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2013/01/18/picloud/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Performance improvements in EF5</title>
		<link>http://rogeralsing.com/2012/10/25/performance-improvements-in-ef5/</link>
		<comments>http://rogeralsing.com/2012/10/25/performance-improvements-in-ef5/#comments</comments>
		<pubDate>Thu, 25 Oct 2012 17:47:48 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1137</guid>
		<description><![CDATA[Just saw this post today: http://www.outofmemory.co.uk/entity-framework-5-dramatically-faster-in-net-4-5/ Kudos to the EF team for great progress :-)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1137&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Just saw this post today:<br />
<a href="http://www.outofmemory.co.uk/entity-framework-5-dramatically-faster-in-net-4-5/">http://www.outofmemory.co.uk/entity-framework-5-dramatically-faster-in-net-4-5/</a></p>
<p>Kudos to the EF team for great progress :-)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1137&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=FQkQE3uVbEA:BOR1s-p2mBc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=FQkQE3uVbEA:BOR1s-p2mBc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=FQkQE3uVbEA:BOR1s-p2mBc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=FQkQE3uVbEA:BOR1s-p2mBc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/FQkQE3uVbEA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/10/25/performance-improvements-in-ef5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>C# – Consume non-async API’s as async</title>
		<link>http://rogeralsing.com/2012/09/24/c-consume-non-async-apis-as-async/</link>
		<comments>http://rogeralsing.com/2012/09/24/c-consume-non-async-apis-as-async/#comments</comments>
		<pubDate>Mon, 24 Sep 2012 12:02:24 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C# 5 Async]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1125</guid>
		<description><![CDATA[Now that we have the new nifty async support built into C# you might wonder how you can access your old API&#8217;s as if they were async. Now before I show any code, I have to warn that the code &#8230; <a href="http://rogeralsing.com/2012/09/24/c-consume-non-async-apis-as-async/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1125&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Now that we have the new nifty async support built into C# you might wonder how you can access your old API&#8217;s as if they were async.</p>
<p><strong>Now before I show any code, I have to warn that the code posted here will only wrap your existing sync methods as a Task of T.<br />
You will be able to consume them<em> as if</em> they were async, and in some cases this might be enough, and in other cases, such as IO scenarios, you really should rewrite the methods to use the proper async versions of the IO methods.</strong></p>
<p>The wrapper code provided here may still be a decent start for you to do this, since you can start migrating code to use async calls, while you rewrite the methods that need rewriting later.</p>
<pre class="brush: csharp; title: ; notranslate">

    class Program
    {
        static void Main(string[] args)
        {
            Consumer();
            Console.WriteLine(&quot;----&quot;);
            Console.ReadLine();
        }


        private async static void Consumer()
        {
            //consume the sync method as if it was async
            var b = await Wrap(() =&gt; NonAsyncMethod(1, &quot;&quot;));
            Console.WriteLine(&quot;got result back {0}&quot;,b);
        }

        //this might be one of your old or 3rd party methods
        private static int NonAsyncMethod(int a, string b)
        {
            System.Threading.Thread.Sleep(2000); //emulate some slow code
            return 5;
        }

        private static Task&lt;T&gt; Wrap&lt;T&gt;(Func&lt;T&gt; selector)
        {
            return Task.Factory.StartNew(selector);
        }
    }

</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1125&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=3OQeLTpq3vQ:VJEi4w-oNZY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=3OQeLTpq3vQ:VJEi4w-oNZY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=3OQeLTpq3vQ:VJEi4w-oNZY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=3OQeLTpq3vQ:VJEi4w-oNZY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/3OQeLTpq3vQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/09/24/c-consume-non-async-apis-as-async/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>swe: Wombit expanderar i Stockholm</title>
		<link>http://rogeralsing.com/2012/07/10/swe-wombit-expanderar-i-stockholm/</link>
		<comments>http://rogeralsing.com/2012/07/10/swe-wombit-expanderar-i-stockholm/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 13:08:50 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1112</guid>
		<description><![CDATA[This is a notification in Swedish. Jag har precis bytt jobb till Wombit Systemutveckling AB. Vi expanderar i Stockholm. Nu söker vi dig med djupare kompetens inom webbutveckling och då framför allt .Net, EPiServer eller Sharepoint. Våra medarbetare erbjuds kreativa &#8230; <a href="http://rogeralsing.com/2012/07/10/swe-wombit-expanderar-i-stockholm/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1112&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is a notification in Swedish.<br />
Jag har precis bytt jobb till Wombit Systemutveckling AB.</p>
<p>Vi expanderar i Stockholm. Nu söker vi dig med djupare kompetens inom webbutveckling och då framför allt .Net, EPiServer eller Sharepoint.</p>
<p>Våra medarbetare erbjuds kreativa och utmanande uppdrag där de får chansen att utveckla sina kunskaper hos några av Sveriges största företag inom flera olika sektorer och branscher.</p>
<p>Vill du veta mer, kontakta <a href="mailto://roger.alsing@wombit.se">roger.alsing@wombit.se</a> eller<a href="mailto://fredrik.danemark@wombit.se"> fredrik.danemark@wombit.se</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1112&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=e3S_jfyisCk:bTY_S4gwAAg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=e3S_jfyisCk:bTY_S4gwAAg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=e3S_jfyisCk:bTY_S4gwAAg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=e3S_jfyisCk:bTY_S4gwAAg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/e3S_jfyisCk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/07/10/swe-wombit-expanderar-i-stockholm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Functional DDD in F#</title>
		<link>http://rogeralsing.com/2012/07/09/functional-ddd-in-f/</link>
		<comments>http://rogeralsing.com/2012/07/09/functional-ddd-in-f/#comments</comments>
		<pubDate>Mon, 09 Jul 2012 11:50:24 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1105</guid>
		<description><![CDATA[After watching Greg Youngs presentation on Functional DDD (http://skillsmatter.com/podcast/design-architecture/ddd-functional-programming) I decided to give it a try using F# I have to say I was sort of pleasantly surprised how well the entire concept works with a functional language. This is &#8230; <a href="http://rogeralsing.com/2012/07/09/functional-ddd-in-f/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1105&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>After watching Greg Youngs presentation on Functional DDD (<a href="http://skillsmatter.com/podcast/design-architecture/ddd-functional-programming">http://skillsmatter.com/podcast/design-architecture/ddd-functional-programming</a>) I decided to give it a try using F#</p>
<p>I have to say I was sort of pleasantly surprised how well the entire concept works with a functional language.</p>
<p>This is only a spike on my part so don&#8217;t expect too much, but the code shows how Gregs ideas can be implemented using F#</p>
<pre class="brush: fsharp; title: ; notranslate">
//state for order line items
type LineItem =
    {
        Quantity : float;
        ProductId : int;
    }

//events that can be consumed by the order aggregate root
type OrderEvents =
    | Created of System.DateTime
    | RemovedItemId of int
    | ItemAdded of LineItem

type Order = 
    { //the order state 
        Id : int;
        CreatedDate : System.DateTime;
        Items : list&lt;LineItem&gt;;
    }

    //helper func to create new instances
    static member Create() = 
        { 
            Id = 1; 
            CreatedDate = System.DateTime.Now; 
            Items = []; 
        }

    //event handler, this consumes an event and uses it to construct a new version of the &quot;this&quot; argument
    static member Apply (this,event) = 
        match event with
        | Created(createdDate)      -&gt; 
            {this with CreatedDate = createdDate; }
        | ItemAdded(item)           -&gt; 
            {this with Items = item :: this.Items; }
        | RemovedItemId(productId)  -&gt; 
            {this with Items = this.Items |&gt; List.filter(fun i -&gt; i.ProductId &lt;&gt; productId); }

    
    static member AddItem (productId,quantity) this =
        if quantity &lt;= 0.0 then 
            failwith  &quot;quantity must be a positive number&quot;

        this,ItemAdded { Quantity = quantity; ProductId = productId; }
    
    static member RemoveProduct (productId) this =
        this,RemovedItemId(productId)

[&lt;EntryPoint&gt;]
let main argv =
    let o = Order.Create() 
            |&gt; Order.AddItem (123,5.0) 
            |&gt; Order.Apply
            |&gt; Order.AddItem (555,3.0)
            |&gt; Order.Apply
            |&gt; Order.AddItem (22,2.2)
            |&gt; Order.Apply 
            |&gt; Order.RemoveProduct(123)
            |&gt; Order.Apply

    //do stuff with the order
   
</pre>
<p>The idea here is that instead of using &#8220;Do&#8221; functions like Greg does, I use an &#8220;Apply&#8221; function wich consumes an event which is an F# discriminated union type.<br />
The actual entity state is implemented using F# records, the apply function creates new versions of such record based on previous state and the consumed event.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1105&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=HCjqAUcUR8s:f_lm_qgXpzI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=HCjqAUcUR8s:f_lm_qgXpzI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=HCjqAUcUR8s:f_lm_qgXpzI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=HCjqAUcUR8s:f_lm_qgXpzI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/HCjqAUcUR8s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/07/09/functional-ddd-in-f/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Programming languages and successful projects</title>
		<link>http://rogeralsing.com/2012/06/27/programming-languages-and-successful-projects/</link>
		<comments>http://rogeralsing.com/2012/06/27/programming-languages-and-successful-projects/#comments</comments>
		<pubDate>Wed, 27 Jun 2012 17:56:07 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1101</guid>
		<description><![CDATA[This is just a random reflection on the current status in software dev.The last few years there have been quite a bit of focus on languages rather than technologies, languages like Clojure, Groovy, Scala are making quite a bit of &#8230; <a href="http://rogeralsing.com/2012/06/27/programming-languages-and-successful-projects/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1101&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is just a random reflection on the current status in software dev.<br />The last few years there have been quite a bit of focus on languages rather than technologies, languages like Clojure, Groovy, Scala are making quite a bit of noise now.<br />Just recently I was watching a clip on InfoQ about Clojure based startups and success stories regarding Clojure.</p>
<p>Is it realy the languages that brings that success?<br />Isn&#8217;t it simply that the really smart guys can now find the tools that suits them the best which in turn helps them to succeed?<br />That is, Average Joe will most likely not chose Clojure for his projects since it&#8217;s not mainstream enough for him, so if or when he fails this will not count as a failed Clojure project.</p>
<p>What I&#8217;m saying is that it&#8217;s not the languages but rather people that makes projects successful.<br />Smart people chose the right tools, dumb people does not. Smart people have a higher success rate than dumb people.</p>
<p>If we remove all other languages and make everyone code Clojure, will we have more successful projects then?<br />I&#8217;m pretty sure we won&#8217;t.</p>
<p> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1101&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=O-R4sruI7lM:IyRVINgXv44:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=O-R4sruI7lM:IyRVINgXv44:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=O-R4sruI7lM:IyRVINgXv44:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=O-R4sruI7lM:IyRVINgXv44:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/O-R4sruI7lM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/06/27/programming-languages-and-successful-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Re-uploaded files</title>
		<link>http://rogeralsing.com/2012/02/23/re-uploaded-files/</link>
		<comments>http://rogeralsing.com/2012/02/23/re-uploaded-files/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 08:16:01 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1040</guid>
		<description><![CDATA[My old file host is down so here are some of the old downloads: Genetic Math Gold Parser Sample<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1040&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>My old file host is down so here are some of the old downloads:</p>
<p><a href="http://dl.dropbox.com/u/63708110/GenMath.rar">Genetic Math</a></p>
<p><a href="http://dl.dropbox.com/u/63708110/GoldLinq.zip">Gold Parser Sample</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1040/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1040/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1040&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=j5qH5FNOTxg:Df6Ukro2Yjc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=j5qH5FNOTxg:Df6Ukro2Yjc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=j5qH5FNOTxg:Df6Ukro2Yjc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=j5qH5FNOTxg:Df6Ukro2Yjc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/j5qH5FNOTxg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2012/02/23/re-uploaded-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Fake Fibers using Async CTP</title>
		<link>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 10:39:52 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# 5 Async]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=1004</guid>
		<description><![CDATA[This is another PoC, building recursive code with continuations using the Async CTP. The code creates a fake fiber, which can be suspended and resumed, thus allowing us to &#8220;step&#8221; through its actions. This technique could be useful when building an &#8230; <a href="http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1004&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>This is another PoC, building recursive code with continuations using the Async CTP.</p>
<p>The code creates a fake fiber, which can be suspended and resumed, thus allowing us to &#8220;step&#8221; through its actions.<br />
This technique could be useful when building an interpreting language where you might want to step through the expressions.</p>
<pre class="brush: csharp; title: ; notranslate">
    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Runtime.CompilerServices;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            FakeFiber f = new MyFiber();

            f.Run();
            while (true)
            {
                //tell fiber to continue
                f.Continue();
                Console.ReadLine();
            }
        }
    }

    public class MyFiber : FakeFiber
    {

        //recursive loop that never throws stack overflow
        async void DoLoop(int count)
        {
            await Yield(); //clear callstack

            Console.WriteLine(&quot;{0} {1}&quot;, count, System.Threading.Thread.CurrentThread.ManagedThreadId); 
            
            //we can fetch values from other functions too
            //w/o blowing the call stack
            var i = await IntFunc();
            
            Console.WriteLine(&quot;got func result {0}&quot;,i);
                     
            if (count == 0)
                return;

            DoLoop(count - 1);
        }

        private async Task&lt;int&gt; IntFunc()
        {
            await Yield(); //clear callstack
            return 1;
        }

        public override void Run()
        {
            DoLoop(100000);
        }
    }

    public abstract class FakeFiber
    {
        public abstract void Run();
        private Task currentTask;
        public bool IsCompleted = false;
        public void Continue()
        {
            var task = currentTask;
            if (task != null)
            {
                task.Start();
                task.Wait();
            }
        }

        protected Task Yield()
        {
            currentTask = new Task(() =&gt; { this.currentTask = null; });
            return currentTask;
        }
    }
}

</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/1004/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/1004/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=1004&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=PvLletvaNfE:fJmURTDADNQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=PvLletvaNfE:fJmURTDADNQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=PvLletvaNfE:fJmURTDADNQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=PvLletvaNfE:fJmURTDADNQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/PvLletvaNfE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/15/fake-fibers-using-async-ctp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>F# style Mailbox / Agent using C# async CTP</title>
		<link>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 08:33:54 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=997</guid>
		<description><![CDATA[More info on TPL DataFlow can be found here : http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c Here is a (naive) F# style Mailbox / Agent using the C# async CTP : This way, we can spawn thousands of agents w/o allocating threads for each of &#8230; <a href="http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=997&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>More info on TPL DataFlow can be found here : <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c">http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d5b3e1f8-c672-48e8-baf8-94f05b431f5c</a></p>
<p>Here is a (naive) F# style Mailbox / Agent using the C# async CTP :</p>
<pre class="brush: csharp; title: ; notranslate">
    class Program
    {
        static void Main(string[] args)
        {
            var agents = new List&lt;MyAgent&gt;();
            //create 100 000 agents
            for (int i = 0; i &lt; 100000; i++)
                agents.Add(new MyAgent());

            //buffer some messages
            agents.AsParallel().ForAll(a =&gt; a.Send(DateTime.Now.ToString()));

            //start agents
            agents.AsParallel().ForAll(a =&gt; a.Run());

            //send some more messages
            agents.AsParallel().ForAll(a =&gt; a.Send(DateTime.Now.ToString()));

            Console.ReadLine();
        }
    }

    public class MyAgent : Mailbox&lt;string&gt;
    {
        
        public override async void Run()
        {
            while (true)
            {
                var message = await Receive();                
                Console.WriteLine(&quot;Agent {0} got {1}&quot;,this.Id, message);
            }
        }
    }

    public abstract class Mailbox&lt;T&gt;
    {
        private static int id;

        protected Mailbox()
        {
            this.Id = id++;
        }

        public int Id { get;protected set; }

        BufferBlock&lt;T&gt; buffer = new BufferBlock&lt;T&gt;();

        
        public abstract void Run();
        
        
        public void Send(T message)
        {
            buffer.SendAsync(message);
        }

        protected async Task&lt;T&gt; Receive()
        {
            return await buffer.ReceiveAsync();
        }
    }
</pre>
<p>This way, we can spawn thousands of agents w/o allocating threads for each of them.<br />
The message loop is executed on the threadpool for each iteration and then suspended untill a new message arrives.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/997/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/997/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=997&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=BBQ-LDeVcnc:LH54yoTXvvs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=BBQ-LDeVcnc:LH54yoTXvvs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=BBQ-LDeVcnc:LH54yoTXvvs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=BBQ-LDeVcnc:LH54yoTXvvs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/BBQ-LDeVcnc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/15/f-style-mailbox-agent-using-c-async-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
		<item>
		<title>Consuming WCF services in Silverlight using Async CTP</title>
		<link>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/</link>
		<comments>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 10:57:25 +0000</pubDate>
		<dc:creator>Roger Alsing</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://rogeralsing.com/?p=992</guid>
		<description><![CDATA[Here is a small sample of how you can consume WCF services using the new Async CTP features. Example, filling a listbox with categories of some sort.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=992&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Here is a small sample of how you can consume WCF services using the new Async CTP features.</p>
<p><strong>Example, filling a listbox with categories of some sort.</strong></p>
<pre class="brush: csharp; title: ; notranslate">
private async void FillCategories()
{
    var client = new MyServiceReference.MyServiceClient();
    //yield untill all categories have been fetched.
    var categories = await client.GetCategoriesTaskAsync();
    categoriesListBox.DataContext = categories;
}

..elsewhere..

//this extension makes it possible to get a Task of T back from our service client
public static class MyServiceClientExtensions
{
    public static Task&lt;IList&lt;Category&gt;&gt; 
                GetCategoriesTaskAsync(this MyServiceClient client)
    {
        var taskCompletion = new TaskCompletionSource&lt;IList&lt;Category&gt;&gt;();
        client.GetCategoriesCompleted += (s, e) =&gt;
                {
                    if (e.Error != null)
                        taskCompletion.TrySetException(e.Error);
                    else
                        taskCompletion.TrySetResult(e.Result);
                };
        client.GetCategoriesAsync();

        return taskCompletion.Task;
    }  
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rogeralsing.wordpress.com/992/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rogeralsing.wordpress.com/992/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=rogeralsing.com&#038;blog=2473556&#038;post=992&#038;subd=rogeralsing&#038;ref=&#038;feed=1" width="1" height="1" /><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=oN7OVq9-yM8:rVr5F3z7uMU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=oN7OVq9-yM8:rVr5F3z7uMU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?i=oN7OVq9-yM8:rVr5F3z7uMU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?a=oN7OVq9-yM8:rVr5F3z7uMU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/RogerAlsingWeblog?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/RogerAlsingWeblog/~4/oN7OVq9-yM8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://rogeralsing.com/2011/04/14/consuming-wcf-services-in-silverlight-using-async-ctp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7ac3d313189eb4d3fe101e3aadcd08e2?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
			<media:title type="html">roggan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
