Using critical section
Another Windows synchronization object is critical section. Critical section behaves in the same manner as mutex. However, it can be used only in a single process context, as opposed to mutex, which can be shared among multiple processes. However, a critical section object is allocated faster by the system, with much smaller overhead.
Our following example will use the same task as before, only this time, we will use critical section instead of mutex. We can use critical section here because our entire application executes in a single process context.
Make sure Visual Studio is up and running.
How to do it...
Now let's create our program and explain its structure.
- Create a new empty C++ Windows application named ...