If name is not a null reference (Nothing in Visual Basic) and initiallyOwned is true, the calling thread owns the named mutex only if createdNew is true after the call. Otherwise the thread can request the mutex by calling the WaitOne method.
Use this constructor to apply access control security to a named system mutex when it is created, preventing other code from taking control of the mutex.
This constructor initializes a Mutex object that represents a named system mutex. You can create multiple Mutex objects that represent the same named system mutex.
If the named system mutex does not exist, it is created with the specified access control security. If the named mutex exists, the specified access control security is ignored.
Note |
|---|
| The caller has full control over the newly created Mutex object even if mutexSecurity denies or fails to grant some access rights to the current user. However, if the current user attempts to get another Mutex object to represent the same named mutex, using either a constructor or the OpenExisting method, Windows access control security is applied. |
If the named mutex has already been created with access control security, and the caller does not have MutexRights.FullControl, an exception is thrown. To open an existing named mutex with only those permissions needed for synchronizing thread activities, see the OpenExisting method.
If you specify a null reference (Nothing in Visual Basic) or an empty string for name, a local mutex is created, as if you had called the Mutex(Boolean) constructor. In this case, createdNew is always true.
Because they are system-wide, named mutexes can be used to coordinate resource use across process boundaries.