O'Reilly logo

C++ Multithreading Cookbook by Milos Ljumovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using event

The event synchronization object works as a signal for alerting the thread in a certain manner. It can be used to start or stop an execution, or when a user input is performed, and so on.

We will use the same example as in our previous two topics, with improvement to application behavior by adding an event that will signal the threads that the user wants to abort the execution and end the program. In this way, we will make our application even more user friendly and more responsive to user input.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

Now, let's create our program and explain its structure.

  1. Create a new empty C++ Windows application named concurrent_operations3.
  2. Open Solution Explorer and right-click on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required