🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#8984
From: zoom
Date: Fri, 13 Aug 2004 17:40
38 lines
2201 bytes
What I want in my code is to allow every thread to iterate once when event
is set.

"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:gnsph0pq4c8mfhapah6cideqmbp6gqor5r@4ax.com...
> <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: <411cfd09@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.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: <4105617c$1@newsgroups.borland.com> <4105777f$3@newsgroups.borland.com> <411ccf89@newsgroups.borland.com> <gnsph0pq4c8mfhapah6cideqmbp6gqor5r@4ax.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: <zoom>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4105617c$1@newsgroups.borland.com> <4105777f$3@newsgroups.borland.com> <411ccf89@newsgroups.borland.com> <gnsph0pq4c8mfhapah6cideqmbp6gqor5r@4ax.com>
Subject: Re: Wait for "signal" from another application and/or thread 
Date: Sat, 14 Aug 2004 03:40:25 +1000
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 211.30.68.31
Message-ID: <411cfd09@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1092418825 211.30.68.31 (13 Aug 2004 10:40:25 -0700)
Path: arc1-ca.pugleaf.net!g2news1.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