🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11595

Re: WaitForMultipleObjects in TThread

#11595
From: Detlef
Date: Fri, 30 Jan 2004 13:23
42 lines
2467 bytes
"Oliver Rutsch" <nospam@sympatec.com> schrieb im Newsbeitrag
news:1075463350.186832@post.sympatec.net...
> Hi Kristoffer,
>
> >>Use WaitForMultipleObjects and define an array of events (a terminate
> >>event, your origin event ...). When the wait returns, react on the
> >>WAIT_OBJECT_0 ... WAIT_OBJECT_X return values and let your thread end
> >>gracefully if it receives the terminate event.
> >
> >
> > Thanks, but how do I get the quit message to signal my terminate event?
> > Especially since I'm stuck in the WaitForMultipleObjects call. It's
probably
> > something simple...
>
> I don't know your program, but if you receive a WM_QUIT in your main
> thread, then maybe you have a OnClose handler or something like this. In
> this function get a handle to the terminate event of your thread and set
> it to signaled, for example:
>
> void __fastcall MyForm::OnClose(TObject *Sender)
> {
> SetEvent(MyThread->GetTerminateEventHandle());
> MyThread->WaitFor();
> ...
> }
>
>
> I wouldn't post a message like WM_QUIT to the thread (if it has it's own
> message queue) because you can't wait with the WaitFor... functions and
> at the same time wait for a windows message.

or use a timeout.
Detlef
>
> Bye,
>
> -- 
> Dipl. Ing. Oliver Rutsch
> EMail: Name:orutsch domain:sympatec.com
> Sympatec GmbH Germany
Technical Details
Message-ID: <401a5a93@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40191ff7$1@newsgroups.borland.com> <1075389099.199618@post.sympatec.net> <401a0744$1@newsgroups.borland.com> <1075463350.186832@post.sympatec.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,2e632a3799f22e8b
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-30 05:39:41 PST
Reply-To: "Detlef" <detlef.stute@seatec-gmbh.com>
From: "Detlef" <detlef.stute@seatec-gmbh.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40191ff7$1@newsgroups.borland.com> <1075389099.199618@post.sympatec.net> <401a0744$1@newsgroups.borland.com> <1075463350.186832@post.sympatec.net>
Subject: Re: WaitForMultipleObjects in TThread
Date: Fri, 30 Jan 2004 14:23:01 +0100
Lines: 44
Organization: SEATEC GmbH
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: 80.134.67.197
Message-ID: <401a5a93@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075468947 80.134.67.197 (30 Jan 2004 05:22:27 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail