<?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>Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx</link><description>Work's heading up right now, so this one will be briefer than expected. Windows has its own idea of threading models. In general, each window on the system is owned by a thread, and that thread is responsible for ensuring that the thread is constantly</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#400648</link><pubDate>Tue, 22 Mar 2005 21:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400648</guid><dc:creator>Ryan</dc:creator><description>ummm should this line &amp;quot;that thread is responsible for ensuring that the thread is constantly pumping messages for that thread&amp;quot; read&lt;br&gt;&lt;br&gt;&amp;quot;that thread is responsible for ensuring that the thread is constantly pumping messages for that window&amp;quot;??&lt;br&gt;&lt;br&gt;Ryan</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#400660</link><pubDate>Tue, 22 Mar 2005 22:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400660</guid><dc:creator>CSS</dc:creator><description>We use a thread to read records from a database and inside the thread call sendmessage to let the UI thread know that the records are ready (so it can update it's display). The reason for using SendMessage is that it causes the data reader thread to block until the UI thread has responded to the SendMessage. We've never seen a problem with this code. Is there an issue we should know about?</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#400663</link><pubDate>Tue, 22 Mar 2005 22:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400663</guid><dc:creator>Larry Osterman</dc:creator><description>CSS, as long as there are no interactions between your UI thread and the background thread you should be ok.&lt;br&gt;&lt;br&gt;But if your UI thread ever synchronously attempts to get information from the background thread, you might have a problem.  Your UI thread would be blocked waiting on the background thread, which would be blocked in SendMessage, waiting on the UI thread.&lt;br&gt;&lt;br&gt;Blam.&lt;br&gt;</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#400850</link><pubDate>Wed, 23 Mar 2005 08:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400850</guid><dc:creator>Frederik Slijkerman</dc:creator><description>It is generally safer to use PostMessage, so the UI thread can retrieve data from the worker thread (and possibly enter critical sections) at its leisure.</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#401282</link><pubDate>Thu, 24 Mar 2005 00:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:401282</guid><dc:creator>Rick Brewster</dc:creator><description>Anyone that's really interested in how to do 'background' work while keeping the progress in the foreground should check out two things:&lt;br&gt;&lt;br&gt;1. Two posts on my blog about it, &amp;quot;Progress Dialogs and Background Tasks&amp;quot; parts 1 and 2: &lt;a target="_new" href="http://blogs.msdn.com/rickbrew/archive/2005/01/28/362876.aspx"&gt;http://blogs.msdn.com/rickbrew/archive/2005/01/28/362876.aspx&lt;/a&gt; and &lt;a target="_new" href="http://blogs.msdn.com/rickbrew/archive/2005/02/08/369484.aspx"&gt;http://blogs.msdn.com/rickbrew/archive/2005/02/08/369484.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;2. Paint.NET v2.0's source code. Head straight for the MainForm.DoEffect() method and also refer to the BackgroundEffectRenderer class. &lt;a target="_new" href="http://www.eecs.wsu.edu/paint.net"&gt;http://www.eecs.wsu.edu/paint.net&lt;/a&gt;&lt;br&gt;&lt;br&gt;Number 2 is especially interesting because the UI launches a dispatch thread which then launches 2-4 (or more -- depends on CPU count) worker threads. We initially ran into trouble because we wanted to preemptively stop and restart this in response to what configuration settings the user changed. So the UI thread would execute Stop(), then Join() ... then the dispatch thread would Stop() and Join() all the worker threads ... but if one of the threads was in the middle of raising a progress event (&amp;quot;i'm 13% done!&amp;quot;) we would dealock because it was calling Invoke() back to the main UI thread. Awful circular deadlock.&lt;br&gt;&lt;br&gt;It's written in C# but the concepts are the same. BeginInvoke() just maps to PostMessage() with a custom window message.</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#401650</link><pubDate>Thu, 24 Mar 2005 16:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:401650</guid><dc:creator>Dmitriy</dc:creator><description>Larry could please comments on some API(s), for example DestroyWindow, requirements to be called only from the thread that created the window.</description></item><item><title>re: Concurrency, part way too many3: Concurrency and Windows</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#403187</link><pubDate>Tue, 29 Mar 2005 04:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:403187</guid><dc:creator>Greg Dean</dc:creator><description>I could be mistaken but, in .NET the method Application.DoEvents() will keep the message pumps running.&lt;br&gt;&lt;br&gt;Any comments?</description></item><item><title>Invoke vs BeginInvoke</title><link>http://blogs.msdn.com/larryosterman/archive/2005/03/22/400583.aspx#607616</link><pubDate>Fri, 26 May 2006 03:52:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:607616</guid><dc:creator>Greg Young</dc:creator><description /></item></channel></rss>