<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 Forums - Tech Off - Asynchronous Programming using LINQ Syntax</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Forums/rss"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 Forums - Tech Off - Asynchronous Programming using LINQ Syntax</title>
		<link>http://channel9.msdn.com/Forums</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Forums</link>
	<language>en</language>
	<pubDate>Mon, 20 May 2013 21:27:53 GMT</pubDate>
	<lastBuildDate>Mon, 20 May 2013 21:27:53 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>3</c9:totalResults>
	<c9:pageCount>-3</c9:pageCount>
	<c9:pageSize>-1</c9:pageSize>
	<item>
		<title>Tech Off - Asynchronous Programming using LINQ Syntax</title>
		<description><![CDATA[<p>After reading <a href="http://blogs.msdn.com/wesdyer/archive/2008/01/11/the-marvels-of-monads.aspx">
http://blogs.msdn.com/wesdyer/archive/2008/01/11/the-marvels-of-monads.aspx</a><br />I created a program that enables creating multiple web requests asynchronously. Even the response streams are read using non-blocking IO!<br /><br /><font face="Courier New">var requests = new[] <br />{<br />&nbsp;&nbsp;&nbsp; WebRequest.Create(&quot;</font><a href="http://www.google.com/"><font face="Courier New">http://www.google.com/</font></a><font face="Courier New">&quot;),<br />&nbsp;&nbsp;&nbsp; WebRequest.Create(&quot;</font><a href="http://www.yahoo.com/"><font face="Courier New">http://www.yahoo.com/</font></a><font face="Courier New">&quot;),<br />&nbsp;&nbsp;&nbsp; WebRequest.Create(&quot;</font><a href="/"><font face="Courier New"><a href="http://channel9.msdn.com/">http&#58;&#47;&#47;channel9.msdn.com&#47;</a></font></a><font face="Courier New">&quot;)<br />};<br /><br />var pages = <br />&nbsp;&nbsp;&nbsp; from request in requests select<br />// essentially we are defining the computation here&nbsp;<br />// it does&nbsp;NOT run here<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from response in request.GetResponseAsync()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let stream = response.GetResponseStream()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from html in stream.ReadToEndAsync()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select new { html, response };</font></p>
<p><font face="Courier New">foreach (var page in pages)<br />{<br />&nbsp;&nbsp;&nbsp; page(d =&gt; // do this when the page&nbsp;data is ready<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(d.response.ResponseUri.ToString());<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine(d.html.Substring(0, 40));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.WriteLine();<br />&nbsp;&nbsp;&nbsp; });<br />} // for loop kicks off the calls and does NOT block the main thread.</font></p>
<p><font face="Courier New">Console.ReadKey();</font><br /><br />The code reads like it is synchronous, but it's really not! You get the benefit of easy to read and write code that is also uses non-blocking IO. So it's not using up threads waiting for each request to return.<br /><br />Check out my <a href="http://www.aboutcode.net/2008/01/14/Async&#43;WebRequest&#43;Using&#43;LINQ&#43;Syntax.aspx">
blog post</a> for the code that implements the Continuation Monad and provides the methods required to enable the LINQ syntax.<br />There is no explicit thread at all in my code. It uses the BeginXXX/EndXXX async methods.<br /><br />I think it's amazing how LINQ can be leveraged to things other than querying data - All thanks to its monadic under-pinings.</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/260292#260292</link>
		<pubDate>Wed, 16 Jan 2008 10:22:55 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/260292#260292</guid>
		<dc:creator>Andrew Davey</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/Andrew Davey/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Asynchronous Programming using LINQ Syntax</title>
		<description><![CDATA[<p>Indeed this is one of the benefits of LINQ... - although you still have to create some extension methods (that you are using) which you have hidden away in this post <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/2ea87a5be19d4858b5ef9dfa00bc8636#2ea87a5be19d4858b5ef9dfa00bc8636</link>
		<pubDate>Wed, 16 Jan 2008 11:31:11 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/2ea87a5be19d4858b5ef9dfa00bc8636#2ea87a5be19d4858b5ef9dfa00bc8636</guid>
		<dc:creator>Christian Liensberger</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/littleguru/Discussions/RSS</wfw:commentRss>
	</item>
	<item>
		<title>Tech Off - Asynchronous Programming using LINQ Syntax</title>
		<description><![CDATA[<p>This reminds me of the example that the F# folks wrote about in the &quot;Expert F#&quot; book (page 366 - Fetching Three Web Pages Simultaneously).&nbsp; Nice job converting that to C#!</p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/a9930b8760cd4530a0739dfa00bc8740#a9930b8760cd4530a0739dfa00bc8740</link>
		<pubDate>Sun, 20 Jan 2008 12:29:40 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/260292-Asynchronous-Programming-using-LINQ-Syntax/a9930b8760cd4530a0739dfa00bc8740#a9930b8760cd4530a0739dfa00bc8740</guid>
		<dc:creator>JChung2006</dc:creator>
		<slash:comments>3</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/JChung2006/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>