<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>mfc-background-threads on Roger&#39;s Blog</title>
		<link>https://blog.differentpla.net/series/mfc-background-threads/</link>
		<description>Recent content in mfc-background-threads on Roger&#39;s Blog</description>
		<generator>Hugo</generator>
		<language>en</language>
		
		
		
		
			<lastBuildDate>Tue, 15 Apr 2003 11:54:39 +0000</lastBuildDate>
		
			<atom:link href="https://blog.differentpla.net/series/mfc-background-threads/feed.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Using background threads for long processes in MFC: Background Thread 4</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background4/</link>
				<pubDate>Tue, 15 Apr 2003 11:54:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background4/</guid>
				<description>&lt;p&gt;The reason that our previous example consumes 100% CPU is that it busy-waits while pumping messages. The correct answer&#xA;is to run the dialog box modally. However, we can&amp;rsquo;t (easily) use &lt;code&gt;DoModal&lt;/code&gt;, because this causes ordering problems. Do we&#xA;create the thread or the dialog first?&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Background Thread 3</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background3/</link>
				<pubDate>Tue, 15 Apr 2003 11:53:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background3/</guid>
				<description>&lt;p&gt;One simple way to run the task in the background, while reporting progress, which still allows the dialog to be&#xA;repainted/moved correctly is to busy-wait for the background thread to finish, while pumping messages:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Background Thread 2</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background2/</link>
				<pubDate>Tue, 15 Apr 2003 11:52:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background2/</guid>
				<description>&lt;p&gt;We can solve the problem of the memory leak, and of the premature destructor call, by simply blocking until the thread&#xA;is finished:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Background Thread 1</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background1/</link>
				<pubDate>Tue, 15 Apr 2003 11:51:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-background1/</guid>
				<description>&lt;p&gt;We add another button to the dialog:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-c++&#34; data-lang=&#34;c++&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;CBgthreadDlg&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;OnBackground&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// Run on a background thread. Don&amp;#39;t wait for the thread to exit.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;TaskThread&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;t&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;t&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Start&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;This uses the code from &lt;a href=&#34;https://blog.differentpla.net/blog/2003/04/15/win32-threads-in-c/&#34;&gt;here&lt;/a&gt; to implement the&#xA;thread class:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Foreground Thread 3</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground3/</link>
				<pubDate>Tue, 15 Apr 2003 11:43:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground3/</guid>
				<description>&lt;p&gt;Because we have progress reporting, we can make use of a progress dialog to partially solve all of these problems. In&#xA;Visual C++, select &amp;ldquo;Project|Add To Project|Components and Controls&amp;rdquo;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Foreground Thread 2</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground2/</link>
				<pubDate>Tue, 15 Apr 2003 11:42:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground2/</guid>
				<description>&lt;p&gt;We can deal with the first one (no feedback), by using an hourglass:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Foreground Thread 1</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground1/</link>
				<pubDate>Tue, 15 Apr 2003 11:41:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-foreground1/</guid>
				<description>&lt;p&gt;Initially, we&amp;rsquo;ll run this as a foreground task. This will ensure that the code compiles and works before we get too&#xA;complicated. Also, it&amp;rsquo;ll show why we want this task to run as a background thread.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC: Sidebar: The Task</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-task/</link>
				<pubDate>Tue, 15 Apr 2003 11:30:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-task/</guid>
				<description></description>
			</item>
			<item>
				<title>Using background threads for long processes in MFC</title>
				<link>https://blog.differentpla.net/blog/2003/04/15/bgthreads-intro/</link>
				<pubDate>Tue, 15 Apr 2003 11:20:39 +0000</pubDate>
				<guid>https://blog.differentpla.net/blog/2003/04/15/bgthreads-intro/</guid>
				<description>&lt;p&gt;It&amp;rsquo;s not easy to write a Windows program that takes a long time to do something and yet still seems responsive to the&#xA;user. Consider that you&amp;rsquo;ve got a single task that needs to be finished:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
