Signaling with event wait handles

In the Understanding the .NET synchronization essentials recipe, we used an unsafe way to access the bContinue shared object, and we used the Sleep method to release the processor for one second while waiting for the user to make a choice between continuing and exiting the application. Later, in the Locking and avoiding deadlocks recipe, we've improved our application to be thread–safe by adding locks to ensure exclusive access—again with the Sleep method inside the loop. The Microsoft .NET framework provides signaling objects that are mostly similar to Event, which we have explained in the previous chapters. Those are the AutoResetEvent, ManualResetEvent, ManualResetEventSlim, CountDownEvent, Barrier, and Wait ...

Get C++ Multithreading Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.