O'Reilly logo

Windows® CE 3.0 Application Programming by Marshall Brain, Nick Grattan

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 Mutex Objects

Mutex (or "Mutual Exclusion") kernel objects are used to ensure that global variables or resources are accessed exclusively by a piece of code. In this respect, they provide the same functionality as critical sections. However, they are more flexible. For example, critical sections can only be used to ensure exclusivity within a single process, whereas mutex objects can be used across processes.

The following steps are required when using mutex kernel objects:

  • Create a new mutex or open an existing mutex by calling the function CreateMutex.

  • Call WaitForSingleObject when entering critical code.

  • Call ReleaseMutex when the critical code execution is complete.

  • Call CloseHandle on the mutex when the mutex is no longer required.

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