<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Synchronizing .NET 4 Tasks with the UI Thread</title>
	<atom:link href="http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/feed/" rel="self" type="application/rss+xml" />
	<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/</link>
	<description>Thoughts on C#, WPF, .NET, and programming for Scientific Visualization</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:38:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Reed</title>
		<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/#comment-1858</link>
		<dc:creator>Reed</dc:creator>
		<pubDate>Wed, 02 Nov 2011 18:49:59 +0000</pubDate>
		<guid isPermaLink="false">http://reedcopsey.com/?p=88#comment-1858</guid>
		<description>Paul,

This is required only because there is no overload for TaskFactory.StartNew that takes a TaskScheduler but not the token and creation options.  The only other option is to create the task, then use Task.Start(scheduler).  Otherwise, you need to specify the other items, as the Task API just exposes it that way.

-Reed</description>
		<content:encoded><![CDATA[<p>Paul,</p>
<p>This is required only because there is no overload for TaskFactory.StartNew that takes a TaskScheduler but not the token and creation options.  The only other option is to create the task, then use Task.Start(scheduler).  Otherwise, you need to specify the other items, as the Task API just exposes it that way.</p>
<p>-Reed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/#comment-1857</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Wed, 02 Nov 2011 09:20:49 +0000</pubDate>
		<guid isPermaLink="false">http://reedcopsey.com/?p=88#comment-1857</guid>
		<description>Hi Reed.

when starting a Task directly on the UI thread why the need for the cancellation token and TaskCreationOptions?

thanks
Paul</description>
		<content:encoded><![CDATA[<p>Hi Reed.</p>
<p>when starting a Task directly on the UI thread why the need for the cancellation token and TaskCreationOptions?</p>
<p>thanks<br />
Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver</title>
		<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/#comment-1147</link>
		<dc:creator>Oliver</dc:creator>
		<pubDate>Sat, 09 Oct 2010 11:24:45 +0000</pubDate>
		<guid isPermaLink="false">http://reedcopsey.com/?p=88#comment-1147</guid>
		<description>Thanks for the post, helpful!

A much easier way of approaching threading.</description>
		<content:encoded><![CDATA[<p>Thanks for the post, helpful!</p>
<p>A much easier way of approaching threading.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reed</title>
		<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/#comment-1121</link>
		<dc:creator>Reed</dc:creator>
		<pubDate>Tue, 06 Jul 2010 17:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://reedcopsey.com/?p=88#comment-1121</guid>
		<description>Tillias,

That&#039;s actually not accurate.  The default TaskScheduler, which is what is used when you do Task.Factory.StartNew, will use always use a ThreadPool thread to execute your Task, unless the LongRunning hint is specified, in which case it will use a dedicated thread (in .NET 4&#039;s implementation).  Either way, it should NEVER run on the UI thread, since the UI thread should never be on a ThreadPool thread.  

Tasks will only get scheduled on the current thread when the current thread is a threadpool thread, or the current thread is blocking on the result of a collection of Tasks (including the one that needs to execute).

That being said, if you want to force a task to run on a dedicated thread, you can do so by specifying the LongRunning hint (in the current implementation).  This is a much simpler alternative to creating a custom TaskScheduler.  Using an STA thread scheduler is really overkill, unless you specifically need an STA thread.

-Reed</description>
		<content:encoded><![CDATA[<p>Tillias,</p>
<p>That&#8217;s actually not accurate.  The default TaskScheduler, which is what is used when you do Task.Factory.StartNew, will use always use a ThreadPool thread to execute your Task, unless the LongRunning hint is specified, in which case it will use a dedicated thread (in .NET 4&#8242;s implementation).  Either way, it should NEVER run on the UI thread, since the UI thread should never be on a ThreadPool thread.  </p>
<p>Tasks will only get scheduled on the current thread when the current thread is a threadpool thread, or the current thread is blocking on the result of a collection of Tasks (including the one that needs to execute).</p>
<p>That being said, if you want to force a task to run on a dedicated thread, you can do so by specifying the LongRunning hint (in the current implementation).  This is a much simpler alternative to creating a custom TaskScheduler.  Using an STA thread scheduler is really overkill, unless you specifically need an STA thread.</p>
<p>-Reed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tillias</title>
		<link>http://reedcopsey.com/2009/11/17/synchronizing-net-4-tasks-with-the-ui-thread/#comment-1120</link>
		<dc:creator>tillias</dc:creator>
		<pubDate>Tue, 06 Jul 2010 17:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://reedcopsey.com/?p=88#comment-1120</guid>
		<description>Hi Reed! 
Task doesn&#039;t guarantee that it will be executed in separate thread. I&#039;ve faced several common scenarios where Task&#039;s delegate is executed in GUI thread and thus the application is stuck. Custom TaskScheduler must be used in order to guarantee that task will be executed in separate thread ( and not in the same GUI one).

You can reed about it here: http://tillias.wordpress.com/2010/07/05/net-4-system-threading-tasks-and-wpf-ui-thread/</description>
		<content:encoded><![CDATA[<p>Hi Reed!<br />
Task doesn&#8217;t guarantee that it will be executed in separate thread. I&#8217;ve faced several common scenarios where Task&#8217;s delegate is executed in GUI thread and thus the application is stuck. Custom TaskScheduler must be used in order to guarantee that task will be executed in separate thread ( and not in the same GUI one).</p>
<p>You can reed about it here: <a href="http://tillias.wordpress.com/2010/07/05/net-4-system-threading-tasks-and-wpf-ui-thread/" rel="nofollow">http://tillias.wordpress.com/2010/07/05/net-4-system-threading-tasks-and-wpf-ui-thread/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
 
