I have recently answered a question that contains a blocking queue template that probably suits your needs perfectly:
Multi producer/consumer threads with condition variables...why don't work well?[
^]. Read the answer carefully as it may contain a lot of useful info for you too. The stuff you need from my answer is the
BlockingQueue
template. You can interrupt the sleep at the end of program execution by placing a special item into the queue - in my example I used a NULL pointer for this.
Regarding the CRITICAL_SECTION + windows event combo: Events and critical sections (critical section == lock == mutex) are often used together to do synchronization between multiple threads. An event that is triggered multiple times (not just once) is almost always used with an accompanying lock (critical section or mutex or whatever). If you are a beginner I have a very nice advice for you regarding the use of criticalsection+event combo: Always wait for the event when you don't hold the lock, and always set/reset the event while you are holding the lock. (On holding the lock I mean being entered in the criticalsection). There are some exceptions to this rule but this one helped me a lot in writing correct code when I began with threading.