🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Wait for "signal" from another application and/or thread

#8983
From: Bob Gonder
Date: Fri, 13 Aug 2004 17:03
28 lines
2038 bytes
<zoom> wrote:

>How to make sure that each and every one of the waiting thread be signalled?

You already create the event to not reset, so if you don't reset the
event in your thread code, then all threads will get the event signal.

>void __fastcall TMyThread::Execute()
>{  while (!Terminated){
>    Sleep(rand() % 1000);
>    BOOL WaitResult = (WaitForSingleObject(h1,INFINITE) == WAIT_OBJECT_0);
>   /<<<< What to do on the following line so that every waiting thread be signalled? >>>>
>    if (WaitResult)   ResetEvent(h1);

/* if terminated, leave the event for the other threads */
    if (WaitResult && !Terminated)   ResetEvent(h1);

>    Synchronize(SyncFunc);
>    FCount++;
>  }
>}


>(Note that we may be running multiple instances of the same application)

Don't know what you want to happen in that case. AFAIK, each instance
will have it's own event. They won't know about each other. Do you
want one instance to shut down all instances?
Technical Details
Message-ID: <gnsph0pq4c8mfhapah6cideqmbp6gqor5r@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4105617c$1@newsgroups.borland.com> <4105777f$3@newsgroups.borland.com> <411ccf89@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b6552239fe09c315
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: Wait for "signal" from another application and/or thread 
Date: Fri, 13 Aug 2004 10:03:09 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <gnsph0pq4c8mfhapah6cideqmbp6gqor5r@4ax.com>
References: <4105617c$1@newsgroups.borland.com> <4105777f$3@newsgroups.borland.com> <411ccf89@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: 65.40.118.193
X-Trace: newsgroups.borland.com 1092416586 65.40.118.193 (13 Aug 2004 10:03:06 -0700)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail