<?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 calls to the UI in a multi-threaded application</title>
	<atom:link href="http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/</link>
	<description>Blog about architectural patterns, best practices, coding principles and techniques</description>
	<lastBuildDate>Tue, 02 Apr 2013 00:12:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Groverboy</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-538</link>
		<dc:creator>Groverboy</dc:creator>
		<pubDate>Wed, 23 Jan 2013 00:33:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-538</guid>
		<description>Very nice generalised design, thanks for sharing this.  I&#039;ve been using SynchronizationContext for some time and definitely find it preferable to using Control.BeginInvoke.

A minor criticism: cancellation does not look thread-safe.  The worker thread reads class field stopRequested (QuoteService.Run) and the consumer thread writes to the field (QuoteService.Stop), but there is no thread synchronisation to prevent a race condition.  This means the consumer may call Stop and begin writing to stopRequested when the worker thread reads the field (stopRequested still equals false), resulting in an additional iteration beyond the consumer request to cancel.

Thread synchronisation can be implemented by using either a lock statement or qualifying stopRequested by &#039;volatile&#039;.

So far as I know the race condition here has a minor consequence (potentially delayed cancel) unlike, for example, deposit to/withdrawal from a bank account.  Can anyone think of a situation in which delayed cancel becomes a significant problem?</description>
		<content:encoded><![CDATA[<p>Very nice generalised design, thanks for sharing this.  I&#8217;ve been using SynchronizationContext for some time and definitely find it preferable to using Control.BeginInvoke.</p>
<p>A minor criticism: cancellation does not look thread-safe.  The worker thread reads class field stopRequested (QuoteService.Run) and the consumer thread writes to the field (QuoteService.Stop), but there is no thread synchronisation to prevent a race condition.  This means the consumer may call Stop and begin writing to stopRequested when the worker thread reads the field (stopRequested still equals false), resulting in an additional iteration beyond the consumer request to cancel.</p>
<p>Thread synchronisation can be implemented by using either a lock statement or qualifying stopRequested by &#8216;volatile&#8217;.</p>
<p>So far as I know the race condition here has a minor consequence (potentially delayed cancel) unlike, for example, deposit to/withdrawal from a bank account.  Can anyone think of a situation in which delayed cancel becomes a significant problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-531</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 24 Sep 2012 19:40:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-531</guid>
		<description>Million-dollar article!  Thanks a million!  ;)</description>
		<content:encoded><![CDATA[<p>Million-dollar article!  Thanks a million!  <img src='http://lostechies.com/gabrielschenker/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Freon</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-530</link>
		<dc:creator>Freon</dc:creator>
		<pubDate>Sun, 23 Sep 2012 02:19:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-530</guid>
		<description>Fantastic little mechanism that solves the (thread)=&gt;GUI problem nicely.  Is scaleable and simple.  WIN!</description>
		<content:encoded><![CDATA[<p>Fantastic little mechanism that solves the (thread)=&gt;GUI problem nicely.  Is scaleable and simple.  WIN!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: annamalai</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-374</link>
		<dc:creator>annamalai</dc:creator>
		<pubDate>Fri, 08 Jul 2011 06:42:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-374</guid>
		<description>i fixed it by 
changing syncContext.Post(OnQuoteChanged, args);
to 
 syncContext.Post(delegate
            {
                OnQuoteChanged(arg);
            }, null);</description>
		<content:encoded><![CDATA[<p>i fixed it by <br />
changing syncContext.Post(OnQuoteChanged, args);<br />
to <br />
 syncContext.Post(delegate<br />
            {<br />
                OnQuoteChanged(arg);<br />
            }, null);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: annamalai</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-373</link>
		<dc:creator>annamalai</dc:creator>
		<pubDate>Fri, 08 Jul 2011 04:48:00 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-373</guid>
		<description>i am getting error in this line 
  syncContext.Post(OnQuoteChanged, args); as follows 
The best overloaded method match for &#039;System.Threading.SynchronizationContext.Post(System.Threading.SendOrPostCallback, object)&#039; has some invalid arguments	 

Argument 1: cannot convert from &#039;method group&#039; to &#039;System.Threading.SendOrPostCallback&#039;	 


the function signature is same as mentioned in the example. 
please help is there any changes i need to make</description>
		<content:encoded><![CDATA[<p>i am getting error in this line <br />
  syncContext.Post(OnQuoteChanged, args); as follows<br />
The best overloaded method match for &#8216;System.Threading.SynchronizationContext.Post(System.Threading.SendOrPostCallback, object)&#8217; has some invalid arguments	 </p>
<p>Argument 1: cannot convert from &#8216;method group&#8217; to &#8216;System.Threading.SendOrPostCallback&#8217;	 </p>
<p>the function signature is same as mentioned in the example. <br />
please help is there any changes i need to make</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel N. Schenker</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-36</link>
		<dc:creator>Gabriel N. Schenker</dc:creator>
		<pubDate>Wed, 26 Jan 2011 21:39:14 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-36</guid>
		<description>@Eric: this is just a class inheriting from EventArgs and having two properties Symbol (string) and Quote (decimal) and a constructor which allows to set these properties.</description>
		<content:encoded><![CDATA[<p>@Eric: this is just a class inheriting from EventArgs and having two properties Symbol (string) and Quote (decimal) and a constructor which allows to set these properties.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-35</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Wed, 26 Jan 2011 20:38:23 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-35</guid>
		<description>Small beginner question: What is the QuoteEventArgs. I get this error: &quot;type or namespace could not be found.&quot; in this line public event EventHandler&lt;QuoteEventArgs&gt; QuoteChanged;

If it&#039;s a custom class could you provide an example one?

Thanks for the article it is very nice.</description>
		<content:encoded><![CDATA[<p>Small beginner question: What is the QuoteEventArgs. I get this error: &#8220;type or namespace could not be found.&#8221; in this line public event EventHandler<quoteeventargs> QuoteChanged;</p>
<p>If it&#8217;s a custom class could you provide an example one?</p>
<p>Thanks for the article it is very nice.</quoteeventargs></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mehdi</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-34</link>
		<dc:creator>Mehdi</dc:creator>
		<pubDate>Sun, 20 Jun 2010 06:55:27 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-34</guid>
		<description>I learned a lot from this clear and easy DRY tutorial. This is exactly what i was looking for, Thank you very much.</description>
		<content:encoded><![CDATA[<p>I learned a lot from this clear and easy DRY tutorial. This is exactly what i was looking for, Thank you very much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ...</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-33</link>
		<dc:creator>...</dc:creator>
		<pubDate>Thu, 12 Mar 2009 09:26:03 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-33</guid>
		<description>Sehr wertvolle Informationen! Empfehlen!</description>
		<content:encoded><![CDATA[<p>Sehr wertvolle Informationen! Empfehlen!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ...</title>
		<link>http://lostechies.com/gabrielschenker/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application/#comment-32</link>
		<dc:creator>...</dc:creator>
		<pubDate>Tue, 03 Mar 2009 13:48:40 +0000</pubDate>
		<guid isPermaLink="false">/blogs/gabrielschenker/archive/2009/01/23/synchronizing-calls-to-the-ui-in-a-multi-threaded-application.aspx#comment-32</guid>
		<description>Gute Arbeit hier! Gute Inhalte.</description>
		<content:encoded><![CDATA[<p>Gute Arbeit hier! Gute Inhalte.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
