Article View: borland.public.cppbuilder.nativeapi
Article #11780Re: Does Sleep() in a TThread put the entire Program on hold?
From: Remy Lebeau (TeamB)
Date: Wed, 14 Jan 2004 05:22
Date: Wed, 14 Jan 2004 05:22
27 lines
2327 bytes
2327 bytes
"Rodolfo Frino - Macrosoft" <Microhaven@Atlantis.com> wrote in message news:4004cafd@newsgroups.borland.com... > This answer could be incorrect if the thread creates any windows. > In this case it will be a much better design to use either > MsgWaitForMultipleObjects() or MsgWaitForMultipleObjectsEx() > instead of Sleep(), otherwise your system could fall into a deadlock. A deadlock occurs when "A" waits on "B" which waits on "A", thus creating a circular dependancy that neither thread can be released from. Sleep() does not create deadlocks unless you use INFINITE as the timeout, which you should never need to do anyway. Even the documentation states that only an infinite wait will produce a deadlock when windows are concerned. > Please update your knowledge about Sleep() from the built-in > Windows SDK help files. I'm well aware of those functions. I'm also well aware that under 99% of cases, worker threads do not usually need to create their own windows, all GUI work should be kept in the main thread as much as possible. The main exceptions are DDE and COM. I'm also well aware that the help file is seriously outdated and incomplete, MSDN has more information about the issue than the help file does. Gambit
Technical Details
Message-ID:
<4004d099$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<opr1ova71yeb6hof@newsgroups.borland.com> <400346eb$1@newsgroups.borland.com> <4004cafd@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,fd7e6a3bf57d032f X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-01-13 21:27:27 PST From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <opr1ova71yeb6hof@newsgroups.borland.com> <400346eb$1@newsgroups.borland.com> <4004cafd@newsgroups.borland.com> Subject: Re: Does Sleep() in a TThread put the entire Program on hold? Date: Tue, 13 Jan 2004 21:22:23 -0800 Lines: 29 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 67.22.138.253 Message-ID: <4004d099$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1074057369 67.22.138.253 (13 Jan 2004 21:16:09 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail