<?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>Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx</link><description>Sometimes it&amp;rsquo;s not a big deal, but there are some situations where it&amp;rsquo;s disastrous to call CreateFile on a message pump thread. The problem occurs because CreateFile might take a long time to complete. Conceivably it could actually take HOURS</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#140427</link><pubDate>Mon, 24 May 2004 17:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140427</guid><dc:creator>Raymond Chen</dc:creator><description>If the file has been archived to remote storage (read: magnetic tape), then the delay will be extraordinarly long indeed.</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#140606</link><pubDate>Mon, 24 May 2004 20:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140606</guid><dc:creator>Luc Cluitmans</dc:creator><description>How about the case where the user *expects* some, possibly lengthy, file operation to take place, and expects the operation to have completed when the UI is responsive again. In other words: handling 'Open...' and 'Save...' commands. Doing those inside the UI thread seems logical to me, isn't it?&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#140609</link><pubDate>Mon, 24 May 2004 20:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140609</guid><dc:creator>Larry Osterman</dc:creator><description>This may be the case, but if you do this, you have to be prepared for your application to be totally unresponsive for minutes.  &lt;br&gt;&lt;br&gt;Usually user's won't accept this.&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#140940</link><pubDate>Tue, 25 May 2004 06:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140940</guid><dc:creator>byron</dc:creator><description>&amp;gt; This may be the case, but if you do this, you have to be prepared for your application to be totally unresponsive for minutes.&lt;br&gt;&lt;br&gt;indeed.&lt;br&gt;&lt;br&gt;be aware theat &amp;quot;totally unresponsive&amp;quot; includes repainting the screen.</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#140988</link><pubDate>Tue, 25 May 2004 08:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140988</guid><dc:creator>Thenin</dc:creator><description>In my QA job (in fact it is one of the the company standards) we consider the behavior as buggy/not acceptable if the app stops responding for more than 11-15 secs. &lt;br&gt;If a certain operation may take a long time, UI should indicate that the process is doing fine and is not hanged/looped etc (using progress bars or any sort of animations). &lt;br&gt;And, of course, User should never see the &amp;quot;not responding&amp;quot; state near the app name in Windows Task Manager.&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#141007</link><pubDate>Tue, 25 May 2004 08:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:141007</guid><dc:creator>Serge Wautier</dc:creator><description>Larry,&lt;br&gt;Are you telling us that MFC is buggy ? :-)</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#141144</link><pubDate>Tue, 25 May 2004 12:01:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:141144</guid><dc:creator>Larry Osterman</dc:creator><description>Byron: Absolutely.  Maybe I wasn't strong enough when I said &amp;quot;unresponsive&amp;quot;.&lt;br&gt;&lt;br&gt;Thenin, I'd say if an app is unresponsive for more than about 1 or 2 seconds, it's unacceptable, especially if it happens soon after a user interaction.  I get this with IE on my wife's machine - it'll mysteriously hang, and I notice it immediately.  It's QUITE frustrating.&lt;br&gt;&lt;br&gt;Serge: Does MFC actually open files in the UI thread?&lt;br&gt;&lt;br&gt;I wasn't aware of that.  Heck, I didn't realize that MFC ever opened files.  But then again, I don't tend to use the document model in MFC at all.&lt;br&gt;&lt;br&gt;And if it does, then yes, it's buggy.&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#142508</link><pubDate>Wed, 26 May 2004 19:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:142508</guid><dc:creator>Mike Dimmick</dc:creator><description>MFC has the excuse of being originally developed in the Windows 3.1 days, where of course you couldn't run another task to open your files ;)&lt;br&gt;&lt;br&gt;Changing it now would probably break something obscure.</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#142520</link><pubDate>Wed, 26 May 2004 19:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:142520</guid><dc:creator>B.Y.</dc:creator><description>I think for most apps, it's not a big enough problem to justify the extra time to do the right thing, just showing an hourglass cursor is enough. But if you're writing Windows Explorer, you probably do want to get it right.</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#146388</link><pubDate>Wed, 02 Jun 2004 07:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:146388</guid><dc:creator>Joku</dc:creator><description>I certainly hope LH will fare better on the cases where there is media problem. What I find quite odd is that when plugging in SATA HDD, even the mouse pointer freezes for about 2 seconds - makes me really wonder is that caused on the driver/kernel/hardware or what. If the system HDD starts having problems, it would be nice if a) whole system would not just suddenly freeze b) there would be some user assignable 5 MB of memory available for recovery toolkit that could be used for emergency measures for raw accessing the soon-dead hdd (it could still be readable but not boot again for example).</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#146590</link><pubDate>Wed, 02 Jun 2004 13:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:146590</guid><dc:creator>Larry Osterman</dc:creator><description>Some things will get better, others won't.&lt;br&gt;&lt;br&gt;In the SATA case, if the mouse isn't moving, it sounds like there's some DPC routine that's taking too long - which is likely to be a driver problem.&lt;br&gt;&lt;br&gt;On the other hand, if you're opening a file that's been archived to tape, there is nothing in the world that can possibly make it go faster. If the file's not physically present and needs to be reloaded from a backup tape, it's going to take time to open the file, regardless.&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#146803</link><pubDate>Wed, 02 Jun 2004 16:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:146803</guid><dc:creator>Larry Osterman</dc:creator><description>One other comment about the media problem.  Sometimes when there's a media problem, there's nothing you can do.&lt;br&gt;&lt;br&gt;If you're dealing with a hard disk with bad sectors on it, then it'll take several seconds before the hard disk gives up on the read.  There are external constraints that can't be worked around in software.&lt;br&gt;</description></item><item><title>re: Things not to do, Part 3: Don't call CreateFile on your Windows message pump thread.</title><link>http://blogs.msdn.com/larryosterman/archive/2004/05/24/140396.aspx#199411</link><pubDate>Wed, 28 Jul 2004 08:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:199411</guid><dc:creator>Norman Diamond</dc:creator><description>6/2/2004 9:22 AM Larry Osterman&lt;br&gt;&lt;br&gt;&amp;gt; If you're dealing with a hard disk with bad&lt;br&gt;&amp;gt; sectors on it, then it'll take several&lt;br&gt;&amp;gt; seconds before the hard disk gives up on the&lt;br&gt;&amp;gt; read.&lt;br&gt;&lt;br&gt;For this part of it, this is true and it is an understatement.  If a CD has bad blocks then the machine can hang for several minutes.  But there are two other cases where Windows really is at fault.&lt;br&gt;&lt;br&gt;When attaching a USB hard disk, Windows Explorer hangs for at least several seconds.  This sounds a lot like Joku's comment about SATA hard disks.  (Notice though, this is completely unrelated to the matter of disconnecting USB floppy drives that I commented on elsewhere.  The hang for several seconds is a mere nuisance and does not cause blue screens of death.  If you get a choice of which issues to work on, this one is not a priority.)&lt;br&gt;&lt;br&gt;When an IDE cable picks up noise from unrelated faulty components (e.g. unwanted radio frequency transmissions from other machines in the same room), Windows 2000 has a really serious flaw that Windows NT4 didn't have.  Suppose Windows is installed on a hard drive attached to the IDE primary master, such as drive C:.  Suppose another drive is attached to the IDE primary slave, such as a CD.  Suppose an I/O operation to the slave fails because of noise.  Windows 2000 tries to write a log entry to the primary master, ON THE SAME CABLE.  No blue screen, just a permanent hang.  The only way out is to turn the power off and on.  In Windows NT4 I don't know if it didn't log I/O errors the same way or if the driver was smart enough not to try writing a log entry when recovery had not been completed on the same cable, but anyway Windows NT4 used to survive the experience.</description></item></channel></rss>