Re: event vs volatile bool
From: Arkady Frenkel (arkadyf_at_hotmailxdotx.com)
Date: 11/03/04
- Next message: Arkady Frenkel: "Re: GetThreadTimes..."
- Previous message: Scott McPhillips [MVP]: "Re: event vs volatile bool"
- In reply to: manu: "event vs volatile bool"
- Next in thread: manu: "Re: event vs volatile bool"
- Reply: manu: "Re: event vs volatile bool"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 3 Nov 2004 14:50:22 +0200
In your case it's the same but in really you don't need while loop in the
case of event , just after another thread set event your
WaitForSingleObject will awake and do the business , that difference between
polling scenario vs. notification
Arkady
"manu" <manu@manu.net> wrote in message
news:esp4nYYwEHA.1564@TK2MSFTNGP09.phx.gbl...
> Hi everyone,
>
> Into a service, to communicate between threads, I use to test a volatile
> bool, like g_bRunning:
>
> while (g_bRunning)
> {
> // do the stuff
>
> Sleep(1000);
> }
>
> the other thread set the g_bRunning to false when they want to stop the
> others threads/
>
> what is the differences with: create an event, and wait for it:
>
> while(WaitForSingleObject(hStopEvent, 1000) != WAIT_OBJECT_0)
> {
>
> // do the stuff
> }
>
> ????
>
> thanks
>
>
- Next message: Arkady Frenkel: "Re: GetThreadTimes..."
- Previous message: Scott McPhillips [MVP]: "Re: event vs volatile bool"
- In reply to: manu: "event vs volatile bool"
- Next in thread: manu: "Re: event vs volatile bool"
- Reply: manu: "Re: event vs volatile bool"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|