Article View: borland.public.cppbuilder.nativeapi
Article #14040Re: TThread can't be Resumed when the application is not Active (focused)?
From: Bob Gonder
Date: Sat, 06 Sep 2003 16:59
Date: Sat, 06 Sep 2003 16:59
21 lines
2256 bytes
2256 bytes
Phuoc Can HUA wrote: >> 1) The thread is running without any delay (playing music) even when I >> was using other application in foreground. It only hangs when the >> constructor is called and the main form is not focused. >> For my test, shortly before the next object is instantiated I click on an >> icon on the desk top. The program will lose focus and hang. Ok, something in your main form creates the object which then goes to sleep. Which means it never completes the initialization. Something else somewhere is supposed to call Execute() to wake it up. Where is that code? And is it in a message loop that essentially goes to sleep when it looses focus? Oh, and if you Execute() then Resume() before the Sleep(1) comes back (which would be more likely if your loop has a lower priority being in the background and all)...... I would think that WaitForSingleObject() would be a better solution. You could put an upper limit on the wait time and then handle the error. You also wouldn't miss the flag change while sleeping.
Technical Details
Message-ID:
<fd3klv0iicamj4bleellpjvndjs87bj69h@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!hermes.visi.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<opru1z6kriypkypy@newsgroups.borland.com> <3f593c8b$1@newsgroups.borland.com> <opru2y8rz4ypkypy@newsgroups.borland.com> <opru2z1gloypkypy@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,453649a6bac9d07b X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-09-06 10:01:53 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: TThread can't be Resumed when the application is not Active (focused)? Date: Sat, 06 Sep 2003 09:59:40 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <fd3klv0iicamj4bleellpjvndjs87bj69h@4ax.com> References: <opru1z6kriypkypy@newsgroups.borland.com> <3f593c8b$1@newsgroups.borland.com> <opru2y8rz4ypkypy@newsgroups.borland.com> <opru2z1gloypkypy@newsgroups.borland.com> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.165.106 X-Trace: newsgroups.borland.com 1062867583 67.31.165.106 (6 Sep 2003 09:59:43 -0700) Lines: 23 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!hermes.visi.com!news-out.visi.com!petbe.visi.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail