<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Parallel Programming with .NET : MSDN</title><link>http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx</link><description>Tags: MSDN</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Parallelism in October 2008 MSDN Magazine</title><link>http://blogs.msdn.com/pfxteam/archive/2008/10/02/8974038.aspx</link><pubDate>Thu, 02 Oct 2008 20:57:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974038</guid><dc:creator>toub</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/8974038.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=8974038</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=8974038</wfw:comment><description>&lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc992993.aspx"&gt;October 2008 issue of MSDN Magazine&lt;/a&gt; just went online yesterday, and it's chock full of content on parallelism.&amp;#160; Definitely worth a cover to cover read!&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="671" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="268"&gt;&lt;img src="http://i.msdn.microsoft.com/cc157190.cover(en-us).gif" /&gt; &lt;/td&gt;        &lt;td valign="top" width="401"&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872852.aspx"&gt;Paradigm Shift:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872852.aspx"&gt;Design Considerations For Parallel Programming&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc817396.aspx"&gt;Coding Tools:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc817396.aspx"&gt;Improved Support For Parallelism In The Next Version Of Visual Studio&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc817398.aspx"&gt;Concurrency Hazards:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc817398.aspx"&gt;Solving 11 Likely Problems In Your Multithreaded Code&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc967279.aspx"&gt;Easy Async:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc967279.aspx"&gt;Build Concurrent Apps From Simple F# Expressions&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc966710.aspx"&gt;Editor's Note:&lt;/a&gt;           &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc966710.aspx"&gt;new Thread(ReadEditorsNote).Start(); yourAttention.WaitOne();&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc850829.aspx"&gt;Windows With C++:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc850829.aspx"&gt;Exploring High-Performance Algorithms&lt;/a&gt;          &lt;br /&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872851.aspx"&gt;.NET Matters:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872851.aspx"&gt;False Sharing           &lt;br /&gt;&lt;/a&gt;          &lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872850.aspx"&gt;{ End Bracket }:&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc872850.aspx"&gt;Don&amp;#8217;t Be Afraid To Throw Away Your Work&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8974038" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>Another Parallel Extensions screencast</title><link>http://blogs.msdn.com/pfxteam/archive/2007/12/12/6752602.aspx</link><pubDate>Thu, 13 Dec 2007 02:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6752602</guid><dc:creator>toub</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6752602.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6752602</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6752602</wfw:comment><description>&lt;A class="" href="http://www.danielmoth.com/Blog/" mce_href="http://www.danielmoth.com/Blog/"&gt;Daniel Moth&lt;/A&gt; is on a roll.&amp;nbsp; Two weeks ago he created &lt;A class="" href="http://www.danielmoth.com/Blog/2007/11/parallel-extensions.html" mce_href="http://www.danielmoth.com/Blog/2007/11/parallel-extensions.html"&gt;three great overview screencasts&lt;/A&gt; for &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E848DC1D-5BE3-4941-8705-024BC7F180BA&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E848DC1D-5BE3-4941-8705-024BC7F180BA&amp;amp;displaylang=en"&gt;Parallel Extensions to the .NET Framework&lt;/A&gt;.&amp;nbsp; Today, he released a &lt;A class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=365238#365238" mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=365238#365238"&gt;fourth video&lt;/A&gt;, covering the Task and TaskManager classes.&amp;nbsp; Thanks, Daniel!&amp;nbsp; We'll get this added to the MSDN &lt;A class="" href="http://msdn2.microsoft.com/en-us/concurrency/default.aspx" mce_href="http://msdn2.microsoft.com/en-us/concurrency/default.aspx"&gt;Parallel Computing developer center&lt;/A&gt; soon, but in the meantime, head on over to &lt;A class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=365238#365238" mce_href="http://channel9.msdn.com/ShowPost.aspx?PostID=365238#365238"&gt;Channel 9&lt;/A&gt; and enjoy.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6752602" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Task+Parallel+Library/default.aspx">Task Parallel Library</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>Give Feedback Through the Connect site</title><link>http://blogs.msdn.com/pfxteam/archive/2007/12/04/6655965.aspx</link><pubDate>Tue, 04 Dec 2007 20:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6655965</guid><dc:creator>essey</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6655965.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6655965</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6655965</wfw:comment><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;Have you found any bugs, unknown issues (vs. &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/pfxteam/archive/2007/11/29/6558570.aspx"&gt;&lt;FONT face=Calibri size=3&gt;known issues&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Calibri size=3&gt;), or any wish list items?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Go to our &lt;/FONT&gt;&lt;A href="http://connect.microsoft.com/site/sitehome.aspx?SiteID=516"&gt;&lt;FONT face=Calibri size=3&gt;Connect site&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;, sign up for the Parallel Extensions to the .NET Framework connection, and start giving us direct feedback.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;FONT face=Calibri size=3&gt;While the blog comments and &lt;/FONT&gt;&lt;A href="http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=551&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;forums&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt; are a great way to raise concerns, ask how-to questions, and engage in a dialogue, the Connect site is the best way for you to report an issue or log a feature request--you can file bugs directly into our work items database.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And, the Connect site is great because we can respond to the issue, you can see our progress on it, and others have a chance to see, discuss, and rate what is there.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6655965" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>MSDN Forums</title><link>http://blogs.msdn.com/pfxteam/archive/2007/12/04/6649195.aspx</link><pubDate>Tue, 04 Dec 2007 09:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6649195</guid><dc:creator>toub</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6649195.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6649195</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6649195</wfw:comment><description>There are some great discussions going on over at the &lt;A class="" href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1986&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1986&amp;amp;SiteID=1"&gt;Parallel Extensions forum on MSDN&lt;/A&gt;.&amp;nbsp; &lt;A class="" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e848dc1d-5be3-4941-8705-024bc7f180ba" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e848dc1d-5be3-4941-8705-024bc7f180ba"&gt;Download the CTP&lt;/A&gt;, try out the bits, head on over to the &lt;A class="" href="http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=551&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=551&amp;amp;SiteID=1"&gt;forums&lt;/A&gt;, and get involved!&amp;nbsp; We'd love to hear from you.&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6649195" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>New "Parallel Computing" dev center on MSDN</title><link>http://blogs.msdn.com/pfxteam/archive/2007/11/29/6606521.aspx</link><pubDate>Fri, 30 Nov 2007 04:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6606521</guid><dc:creator>toub</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6606521.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6606521</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6606521</wfw:comment><description>&lt;P&gt;There's a new &lt;A class="" href="http://msdn2.microsoft.com/en-us/concurrency/default.aspx" mce_href="http://msdn2.microsoft.com/en-us/concurrency/default.aspx"&gt;Parallel Computing developer center&lt;/A&gt; on MSDN:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"Microsoft’s Parallel Computing developer center is dedicated to providing information, ideas, community, and technology to developers to make it easier to write programs that perform and scale well on parallel hardware."&amp;nbsp; &lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Check it out!&amp;nbsp; There are already a plethora of resources available at the center, including &lt;A class="" href="http://channel9.msdn.com/Showforum.aspx?forumid=38&amp;amp;tagid=269" mce_href="http://channel9.msdn.com/Showforum.aspx?forumid=38&amp;amp;tagid=269"&gt;several great videos&lt;/A&gt; from &lt;A class="" href="http://www.danielmoth.com/Blog/2007/11/parallel-extensions-videos-errata.html" mce_href="http://www.danielmoth.com/Blog/2007/11/parallel-extensions-videos-errata.html"&gt;Daniel Moth&lt;/A&gt; on using Parallel Extensions.&amp;nbsp; We'll be populating the site with more in the coming weeks and months (if there are any resources you feel should be added, please let us know).&lt;/P&gt;
&lt;P&gt;In addition to the dev center, there are forums for discussing &lt;A class="" href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1985&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1985&amp;amp;SiteID=1"&gt;parallel computing in general&lt;/A&gt; as well as &lt;A class="" href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1986&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=1986&amp;amp;SiteID=1"&gt;Parallel Extensions&lt;/A&gt;, and there's a &lt;A class="" href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=516" mce_href="https://connect.microsoft.com/site/sitehome.aspx?SiteID=516"&gt;Microsoft Connect site&lt;/A&gt; for submitting bugs and feature requests.&lt;/P&gt;
&lt;P&gt;We'd love to hear from you.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6606521" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>PLINQ changes since the MSDN Magazine article</title><link>http://blogs.msdn.com/pfxteam/archive/2007/11/29/6558508.aspx</link><pubDate>Thu, 29 Nov 2007 18:20:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6558508</guid><dc:creator>toub</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6558508.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6558508</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6558508</wfw:comment><description>&lt;P&gt;I &lt;A class="" href="http://blogs.msdn.com/pfxteam/archive/2007/11/29/6558543.aspx" mce_href="http://blogs.msdn.com/pfxteam/archive/2007/11/29/6558543.aspx"&gt;posted&lt;/A&gt; about changes we've made to the Task Parallel Library since we published the MSDN Magazine article outlining its design.&amp;nbsp; In this post, I'll do the same thing for PLINQ.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Most of the &lt;A href="http://msdn.microsoft.com/msdnmag/issues/07/10/PLINQ" mce_href="http://msdn.microsoft.com/msdnmag/issues/07/10/PLINQ"&gt;October 2007 article on PLINQ&lt;/A&gt; is still accurate.&amp;nbsp;&amp;nbsp; After all, PLINQ is largely an implementation of the .NET Standard Query Operators, and thus its API is predominantly dictated by the API shipped in the .NET Framework 3.5.&amp;nbsp; However, there are APIs exposed by PLINQ that are not part of the .NET Standard Query Operators (such as the most visible member of PLINQ, AsParallel), and there are also behavioral differences that manifest due to its very nature as a parallel implementation versus the sequential implementation that exists today.&amp;nbsp; Since the MSDN article was published, there have been a few changes to both of these, and I'll outline those differences here.&lt;/P&gt;
&lt;P&gt;First, as with the Task Parallel Library, PLINQ is not contained in System.Concurrency.dll as is claimed by the article.&amp;nbsp; We've since moved all of this functionality&amp;nbsp;to the System.Threading.dll assembly, which is what you'll need to reference to access PLINQ functionality in your .NET projects as of this CTP.&lt;/P&gt;
&lt;P&gt;Next, the article shows the AsParallel extension method as living on the System.Linq.ParallelEnumerable class.&amp;nbsp; This method has migrated to the new System.Linq.ParallelQuery class.&amp;nbsp; Of course, given its primary use as an extension method for IEnumerable&amp;lt;T&amp;gt;, and given that ParallelQuery is in the same namespace and assembly as ParallelEnumerable, the change in declaring type doesn't really affect the programming model, as the change isn't at all visible in code using AsParallel as an extension method.&lt;/P&gt;
&lt;P&gt;Moving on, the article states that "parallelism doesn’t get introduced until you start processing the output of the query. If you’re familiar with IEnumerable&amp;lt;T&amp;gt;, this equates to calling the GetEnumerator method."&amp;nbsp; Of course, if you're very familiar with LINQ, you'll know that the query isn't actually evaluated until MoveNext() is called on the IEnumerator&amp;lt;T&amp;gt; returned from GetEnumerator.&amp;nbsp; PLINQ behaves in the same way... none of the data in the query will be processed until MoveNext() is called.&lt;/P&gt;
&lt;P&gt;The next change is important to keep in mind.&amp;nbsp; Here's the original MSDN article text:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"...pipelined processing, in which case the thread doing&lt;BR&gt;the enumeration is separate from the threads devoted to running&lt;BR&gt;the query. PLINQ will use many threads for query execution, but will reduce the degree of parallelism by one so that the enumerating thread is not interfered with. For instance, if you have eight processors available, seven of them will run the PLINQ query while the remaining processor runs the foreach loop on the output of the PLINQ query as elements become available. This carries the benefit of allowing more incremental processing of output, thus reducing the memory requirements necessary to hold the results; however, having many producer threads and only a single consumer thread can often lead to uneven work distribution, resulting in processor inefficiency."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This was true at the time the article was written, but for a variety of reasons we've changed the behavior since.&amp;nbsp; Now, when using pipelining (the default when iterating over a query with foreach) we don't decrease the degree of parallelism.&amp;nbsp; If you still want such behavior, you can take advantage of the AsParallel overload that accepts the degree of parallelism as an argument, and provide to it Environment.ProcessorCount-1.&amp;nbsp; Why did we change this?&amp;nbsp; The reasoning described in the article is sound, however there were other competing factors that, in the end, we decided were more important.&amp;nbsp; As an example of one of these, consider the computer you're currently reading this on... is it a dual-core?&amp;nbsp; A quad-core?&amp;nbsp; One of those is likely.&amp;nbsp; And if you were to iterate over a PLINQ query with the aforementioned pipelining behavior on a dual-core machine, guess how many threads would be used to process the query.&amp;nbsp; One.&amp;nbsp; That's very likely not what you'd expect from a parallel LINQ implementation. 
&lt;P&gt;Next (and very minor), the article describes an overload of IParallelEnumerable.GetEnumerator that accepts a Boolean parameter named pipelined that determines whether pipelining will be used when executing the query.&amp;nbsp; This parameter has been renamed to usePipelining.&amp;nbsp; Note, however, that we've already received feedback about this design (e.g. using a Boolean&amp;nbsp;argument&amp;nbsp;to enable/disable pipelining), and we'll be reevaluating it in the future. 
&lt;P&gt;In the section of the article covering concurrent exceptions, System.Concurrency.MultipleFailuresException is mentioned.&amp;nbsp; This exception type still exists and behaves as is described in the article, however it's been renamed.&amp;nbsp; The exception type is now System.Threading.AggregateException and is the same exception type used for this purpose across all of the Parallel Extensions to the .NET Framework.&amp;nbsp; Additionally, the article mentions that the InnerExceptions property is an array of Exception instances; the AggregateException.InnerExceptions property is now a ReadOnlyCollection&amp;lt;Exception&amp;gt;.&lt;/P&gt;
&lt;P&gt;When discussing order preservation in PLINQ queries, the article mentions that QueryOptions.PreserveOrdering can be provided as a parameter to the AsParallel method.&amp;nbsp; This capability still exists, but the name has been changed slightly to ParallelQueryOptions.PreserveOrdering.&lt;/P&gt;
&lt;P&gt;I believe those are the primary API/behavioral differences between the article and the current CTP release of PLINQ.&amp;nbsp; If you find any other significant differences, please us know, and we'll augment the information provided here.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6558508" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/PLINQ/default.aspx">PLINQ</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item><item><title>Task Parallel Library changes since the MSDN Magazine article</title><link>http://blogs.msdn.com/pfxteam/archive/2007/11/29/6558543.aspx</link><pubDate>Thu, 29 Nov 2007 18:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6558543</guid><dc:creator>toub</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/pfxteam/comments/6558543.aspx</comments><wfw:commentRss>http://blogs.msdn.com/pfxteam/commentrss.aspx?PostID=6558543</wfw:commentRss><wfw:comment>http://blogs.msdn.com/pfxteam/rsscomments.aspx?PostID=6558543</wfw:comment><description>&lt;P&gt;Back in the October 2007 issue of MSDN Magazine, &lt;A href="http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx" mce_href="http://msdn.microsoft.com/msdnmag/issues/07/10/Futures/default.aspx"&gt;we published an article&lt;/A&gt; on the beginning stages of what has become the Task Parallel Library (TPL)&amp;nbsp;that's part of the Parallel Extensions to the .NET Framework.&amp;nbsp; While the core of the library and the principles behind it have remained the same, as with any piece of software in the early stages of its lifecycle, the design changes frequently. In fact, one of the reasons we've put out an early community technology preview (CTP) of Parallel Extensions is to solicit your feedback on the APIs so that we know if we're on the right track, how we may need to change them further, and so forth.&amp;nbsp; Aspects of the API have already&amp;nbsp;changed since the article was published, and here we'll go through the differences.&lt;/P&gt;
&lt;P&gt;First, the article refers to System.Concurrency.dll and the System.Concurrency namespace.&amp;nbsp;&amp;nbsp;We've since changed the name of the DLL to System.Threading.dll, and TPL is now contained in two different namespaces, System.Threading and System.Threading.Tasks.&amp;nbsp; AggregateException, the higher-level Parallel class, and Parallel's supporting types (ParallelState and ParallelState&amp;lt;TLocal&amp;gt;) are contained in System.Threading, while all of the lower-level task parallelism types are&amp;nbsp;in System.Threading.Tasks.&lt;/P&gt;
&lt;P&gt;Next, the second page of the article states "if any exception is thrown in any of the iterations, ... the first thrown exception is rethrown in the calling thread."&amp;nbsp; The semantics here have changed such that we now have a common exception handling model across all of the Parallel Extensions, including PLINQ.&amp;nbsp; If an exception is thrown, we still cancel all unstarted iterations, but rather than just rethrowing one exception, we bundle all thrown exceptions into an AggregateException container exception and throw that new exception&amp;nbsp;instance.&amp;nbsp; This allows developers to see all errors that occurred, which can be important for reliability.&amp;nbsp; It also preserves the stack traces of the original exceptions.&lt;/P&gt;
&lt;P&gt;In the section on aggregation, the article talks about the Parallel.Aggregate API.&amp;nbsp; Since the article was published, we've dropped this method from the Parallel class.&amp;nbsp; Why?&amp;nbsp; Because a) PLINQ already supports parallel aggregation through the ParallelEnumerable.Aggregate extension method, and b) because aggregation can be implemented with little additional effort on top of Parallel.For if PLINQ's support for aggregation isn't enough.&amp;nbsp; Consider the example shown in the article:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int sum = Parallel.Aggregate(0, 100, 0,&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(int i) { return isPrime(i) ? i : 0; },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(int x, int y) { return x + y; });&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We can implement this with PLINQ as follows:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int sum = (from i in ParallelEnumerable.Range(0, 99)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where isPrime(i)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select i).Sum();&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course, this benefits from LINQ and PLINQ already supporting a Sum method.&amp;nbsp; We can do the same thing using the Aggregate method for general reduction support:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int sum = (from i in ParallelEnumerable.Range(0, 99)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where isPrime(i)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select i).Aggregate((x,y) =&amp;gt; x+y);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If we prefer not to use PLINQ, we can do a similar operation using Parallel.For (in fact, this is very similar to how Parallel.Aggregate was implemented internally):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int sum = 0;&lt;BR&gt;Parallel.For(0, 100, () =&amp;gt; 0, (i,state)=&amp;gt;&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (isPrime(i)) state.ThreadLocalState += i;&lt;BR&gt;},&lt;BR&gt;partialSum =&amp;gt; Interlocked.Add(ref sum, partialSum));&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Here, we're taking advantage of the overload of Parallel.For that supports thread-local state.&amp;nbsp; On each thread involved in the Parallel.For loop, the thread-local state is initialized to 0 and is then incremented by the value of every prime number processed by that thread.&amp;nbsp; After the thread has completed processing all iterations it's assigned, it uses an Interlocked.Add call to store the partial sum into the total sum.&amp;nbsp; In fact, if you found yourself needing Aggregate functionality a lot, you could generalize this into your own ParallelAggregate method, something like the following:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;static T ParallelAggregate&amp;lt;T&amp;gt;(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int fromInclusive, int toExclusive, T seed, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Action&amp;lt;int&amp;gt; selector, Action&amp;lt;T,T&amp;gt; aggregator)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; T result =&amp;nbsp;seed;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; object aggLock = new object();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parallel.For(fromInclusive, toExclusive, () =&amp;gt; initialValue, (i,state) =&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; state.ThreadLocalState = &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggregator(state.ThreadLocalState, selector(i));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; partial =&amp;gt; { lock(aggLock) result = aggregator(partial, result); } );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result;&lt;BR&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With this, you can use ParallelAggregate just as is done with Parallel.Aggregate in the article:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;int sum = ParallelAggregate(0, 100, 0, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(int i) { return isPrime(i) ? i : 0; },&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delegate(int x, int y) { return x + y; });&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Moving on to the Task class, we've made some fairly substantial changes to the public facing API.&amp;nbsp;&amp;nbsp;Here's a summary of the differences from what's described in the article:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;As shown in the article, Task does not have a base class.&amp;nbsp; In the CTP, Task now derives from TaskCoordinator, a base class which provides all of the waiting and cancelation functionality. 
&lt;LI&gt;The Task class described in the article exposes a constructor that accepts an Action delegate.&amp;nbsp; During construction, the Task is queued for execution.&amp;nbsp; Instead, we changed this so that Task doesn't expose any constructors.&amp;nbsp; Tasks are now created using the Task.Create static method; we felt this factory approach was clearer than the constructor approach... please let us know what you think regarding this change.&amp;nbsp; Were we right?&amp;nbsp; Is one approach better than the other?&amp;nbsp; Would it be a positive or a negative if both approaches were supported? 
&lt;LI&gt;The type of the delegate used by Task.Create is Action&amp;lt;Object&amp;gt; rather than just Action, and overloads of Task.Create support providing a state argument that will be passed to the Task's action. 
&lt;LI&gt;The article states that calling Cancel on a Task will cancel that task and all of the tasks that task created.&amp;nbsp; We've modified this approach so that the model is now opt-in, meaning that by default tasks created by a task will not be canceled when the parent task is canceled.&amp;nbsp; That behavior can be opted into, however, by specifying the RespectParentCancelation flag when the child Task instances are created. 
&lt;LI&gt;The article describes a Task&amp;lt;T&amp;gt; type that derives from Task.&amp;nbsp; This has been renamed Future&amp;lt;T&amp;gt;.&amp;nbsp; As with Task, it no longer exposes a constructor that accepts a Func&amp;lt;T&amp;gt; delegate.&amp;nbsp; Instead, Future&amp;lt;T&amp;gt; provides a static Create factory method.&amp;nbsp; In addition, to better support type inference, we provide a non-generic Future class that exposes generic static Create&amp;lt;T&amp;gt; methods.&amp;nbsp; This makes it possible to create a Future&amp;lt;T&amp;gt; where T is an anonymous type returned from the provided Func&amp;lt;T&amp;gt;. 
&lt;LI&gt;The article describes the ReplicableTask class as deriving from Task.&amp;nbsp; For the CTP, we've gotten rid of ReplicableTask, but we've kept the concept.&amp;nbsp; To create a Task as a replicable task, provide the TaskCreationOptions.SelfReplicating value to the Task.Create method when creating the Task. 
&lt;LI&gt;The article describes the exception handling model for self-replicating tasks being one where only one exception is rethrown even if multiple exceptions were thrown from multiple invocations of the replicable task.&amp;nbsp; As with the loop exception handling model described earlier, we now collect all thrown exceptions into one new AggregateException and throw that exception instead of picking one of the thrown exceptions at random.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;In addition to changes to the Task class, there have also been changes to the TaskManager class described in the article:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In the article, TaskManager exposed two constructors, one that's parameterless and one that accepts an integer representing the maximum concurrency level for the TaskManager.&amp;nbsp; We've modified that second constructor to instead accept a TaskManagerPolicy, a type which represents the allowed behavior of the TaskManager, providing information such as desired concurrency level and execution context flow behavior. 
&lt;LI&gt;Similarly, rather than exposing a MaxConcurrentThreads property, TaskManager now exposes a TaskManagerPolicy property, which allows the current policy to be retrieved and a new policy to be provided dynamically. 
&lt;LI&gt;The article shows Task providing a constructor that accepts a TaskManager, in order to associate that Task with a specific TaskManager.&amp;nbsp; Such behavior is still possible, but the TaskManager is provided to overloads of Task.Create.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;That sums up the changes we've made.&amp;nbsp; Even with these changes, the article should still provide you with a good overview of the library and its intended usage.&amp;nbsp; For more information, check out the documentation that's included with the CTP, and stay tuned to this blog!&amp;nbsp; As mentioned before, we're very interested in your feedback on the API, so please let us know what you think (the good and the bad).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6558543" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Task+Parallel+Library/default.aspx">Task Parallel Library</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Code+Samples/default.aspx">Code Samples</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/Parallel+Extensions/default.aspx">Parallel Extensions</category><category domain="http://blogs.msdn.com/pfxteam/archive/tags/MSDN/default.aspx">MSDN</category></item></channel></rss>