<?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>Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx</link><description>In the June 2008 CTP of Parallel Extensions to the .NET Framework , we introduced the ContinueWith method on both Task and Future&amp;lt;T&amp;gt;. ContinueWith is, in effect, a callback, very much like events in .NET. With events, a causal action results in</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#8770422</link><pubDate>Fri, 25 Jul 2008 02:16:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8770422</guid><dc:creator>art_scott@msn.com</dc:creator><description>&lt;p&gt;Hi toub.&lt;/p&gt;
&lt;p&gt;When I get a 42 core multi-core system...&lt;/p&gt;
&lt;p&gt;I'd like to watch 42 HD-DVD's in 42 windows at the same time...&lt;/p&gt;
&lt;p&gt;Is ContinueWith a useful abstraction for that scenario? (Maybe I need 1024 cores?)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;art&lt;/p&gt;
</description></item><item><title>re: Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#8772169</link><pubDate>Fri, 25 Jul 2008 16:41:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8772169</guid><dc:creator>Chernichkin Stanislav</dc:creator><description>&lt;p&gt;Hi toub!&lt;/p&gt;
&lt;p&gt;Currently I’m writing network communication application which relies on .net APM (IAsyncResult + Begin... End… methods). I use this pattern because I want to minimize thread blocking. Threads are quite expensive, so I can’t allow thread just wait for response from remote system wasting system resources. The problem is that my code becomes too complicated quickly, especially when I introduce task cancelation, fault handling and time-outs. Currently I’m looking for simplified pattern to replace .net APM and, probably, standard library, written by someone else (ok, MS will suite me well :). Parallel Extensions to the .NET Framework seems to be good choice but I’m steel missing some functionality.&lt;/p&gt;
&lt;p&gt;The first is the Task in non-blocking scenarios. In “Wrapping an APM implementation with Future&amp;lt;T&amp;gt;” you wrote how to use Future to implement non-blocking &amp;nbsp;APM pattern wrapping, but lot of methods does not produce result, so using Task for wrapping would be preferred.&lt;/p&gt;
&lt;p&gt;Second is Future chaining. Consider I have some service, which should process request sequentially in some order (FIFO in most cases, but more complex scenarios also possible). I need to implement non-blocking post method, which will schedule request for execution. Also, due to limited numbers of threads, I can’t allocate separate thread for each service, thread should be allocated only when it needed and released when work is done. &amp;nbsp;Currently I’m using something like this:&lt;/p&gt;
&lt;p&gt;public Future&amp;lt;Result&amp;gt; Process()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;	var newFuture = Future&amp;lt;Result&amp;gt;.Create();&lt;/p&gt;
&lt;p&gt;	var prevFuture = Interlocked.Exchange(ref PrevFuture, newFuture);&lt;/p&gt;
&lt;p&gt;	if (prevFuture != null)&lt;/p&gt;
&lt;p&gt;		prevFuture.ContinueWith(delegate&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;// here “if (!newFuture.IsCanceled)” may be placed&lt;/p&gt;
&lt;p&gt;			OnProcess(newFuture);&lt;/p&gt;
&lt;p&gt;		});&lt;/p&gt;
&lt;p&gt;	else&lt;/p&gt;
&lt;p&gt;		OnProcess(newFuture);&lt;/p&gt;
&lt;p&gt;	return newFuture;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;where OnProcess() starts non-blocking APM method and subscribes to result. &amp;nbsp;As you can see in this approach nearly unnecessary short running task created, the only work of which is to start non-blocking asynchronous operation. It would be nice to have some standard method to chain APM method wrappers.&lt;/p&gt;
</description></item><item><title>Waiting for Tasks</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#8835613</link><pubDate>Wed, 06 Aug 2008 04:52:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8835613</guid><dc:creator>Parallel Programming with .NET</dc:creator><description>&lt;p&gt;Parallel Extensions makes it easy to wait for Tasks to complete.&amp;amp;#160; Task exposes a Wait method, which&lt;/p&gt;
</description></item><item><title>re: Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#9220491</link><pubDate>Mon, 15 Dec 2008 15:56:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9220491</guid><dc:creator>Urs Gleim</dc:creator><description>&lt;p&gt;Hi toub,&lt;/p&gt;
&lt;p&gt;regarding your ContinueWhenAll example.&lt;/p&gt;
&lt;p&gt;Why don't you just do this?:&lt;/p&gt;
&lt;p&gt;Task.WaitAll(t1, t2);&lt;/p&gt;
&lt;p&gt;Task.Create(delegate { Console.WriteLine(&amp;quot;t1 and t2 finished&amp;quot;); });&lt;/p&gt;
&lt;p&gt;What is the difference to your ContinueWhenAll?&lt;/p&gt;
&lt;p&gt;Cheers, Urs&lt;/p&gt;
</description></item><item><title>re: Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#9258873</link><pubDate>Wed, 31 Dec 2008 23:07:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9258873</guid><dc:creator>wekempf</dc:creator><description>&lt;p&gt;Urs,&lt;/p&gt;
&lt;p&gt;WaitAll blocks, while ContinueWhenAll does not. &amp;nbsp;ContinueWhenAll just schedules a delegate to run when all tasks are complete, and then continues on, while WaitAll blocks the current thread until all the tasks are complete. &amp;nbsp;This is an important distinction.&lt;/p&gt;
</description></item><item><title>re: Useful Abstractions Enabled with ContinueWith</title><link>http://blogs.msdn.com/pfxteam/archive/2008/07/23/8768673.aspx#9404695</link><pubDate>Sat, 07 Feb 2009 17:20:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9404695</guid><dc:creator>Alberto Fuentes</dc:creator><description>&lt;p&gt;.Net 4.0 is going to be very interesting to exploit multicore processors. However, do you know a due date?&lt;/p&gt;
&lt;p&gt;In the meantime, I began working with multicore programming using current C# 2008, as I need more performance in some batch processes.&lt;/p&gt;
&lt;p&gt;I bought the book for beginners by Packt Publishing: &amp;quot;C# 2008 and 2005 Threaded Programming: Beginner’s Guide&amp;quot;, by Gaston C. Hillar - &lt;a rel="nofollow" target="_new" href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book"&gt;http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The book covers a few chapters about Parallel Extensions. However, it also teaches to use the current threading model. I am achieving amazing results with my dual core CPU.&lt;/p&gt;
&lt;p&gt;Recommended for those who are trying to program for multicore CPUs.&lt;/p&gt;
&lt;p&gt;I can't wait to see Visual Studio 2010 in the market.&lt;/p&gt;
&lt;p&gt;But, please, provide a date!!!&lt;/p&gt;
</description></item></channel></rss>