What is a .NET Mutex?

https://msdn.microsoft.com/en-us/library/system.threading.mutex(v=vs.110).aspx

  • a primitive .NET type
  • one thread owns it at a time
  • WaitOne(int)
    • blocks the calling thread
    • returns true when no threads own it
    • then gives ownership to the calling thread
    • otherwise, returns false when the timeout expires
  • similar to the Semaphore .NET type
    • but only the owner of a Mutex can release a Mutex,
    • and Mutex scope can pass application domain boundaries
  • scope
    • a local, unnamed Mutex has process scope
    • a system, named Mutex has operating system scope
  • use case examples: