Article View: borland.public.cppbuilder.nativeapi
Article #5789Re: SendMessage() repetition error
From: Bob Gonder
Date: Fri, 01 Jul 2005 01:48
Date: Fri, 01 Jul 2005 01:48
22 lines
1798 bytes
1798 bytes
Daniel Stevenson wrote:
>I've got an application (ie. Papa.exe) that executes a second application
>(Bubba.exe).
>
>Pappa has to wait until Bubba.exe has finished executing before continuing
>so I have used SendMessage() to tell Papa.exe when it is finished.
Seems like a lot of work.
The usual way is to call
if( CreateProcess() )
{ WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess);
CloseHandle( pi.hThread);
That way you don't have to rely on Bubba to complete normally.
That is, if Bubba aborts for some reason, you don't sit there waiting
for a message that will never come.
Now, if you want to take into account that Bubba might hang, then
either put a reasonable timeout instead of INFINITE, or have the
CreateProcess in a second thread so the main thread can stay awake and
time out and terminate Bubba.
Technical Details
Message-ID:
<5m79c1hbsaqql34t2nust89hmhmcodg5n9@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<42c49259@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,696995b85f90e7d7 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: SendMessage() repetition error Date: Thu, 30 Jun 2005 18:48:31 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <5m79c1hbsaqql34t2nust89hmhmcodg5n9@4ax.com> References: <42c49259@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 71.0.135.246 X-Trace: newsgroups.borland.com 1120182511 71.0.135.246 (30 Jun 2005 18:48:31 -0700) Lines: 24 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!peer01.west.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail