Mutex Constructor
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Initializes a new instance of the Mutex class with a Boolean value that indicates whether the calling thread should have initial ownership of the mutex, and a string that is the name of the mutex.
Namespace: System.Threading
Assembly: mscorlib.Extensions (in mscorlib.Extensions.dll)
Syntax
'Declaration
<SecuritySafeCriticalAttribute> _
Public Sub New ( _
initiallyOwned As Boolean, _
name As String _
)
[SecuritySafeCriticalAttribute]
public Mutex(
bool initiallyOwned,
string name
)
Parameters
- initiallyOwned
Type: System.Boolean
true to give the calling thread initial ownership of the named system mutex if the named system mutex is created as a result of this call; otherwise, false.
- name
Type: System.String
The name of the Mutex. If the value is nulla null reference (Nothing in Visual Basic), the Mutex is unnamed.
Exceptions
Exception | Condition |
---|---|
UnauthorizedAccessException | The named mutex exists and has access control security, but the user does not have MutexRights.FullControl. |
ApplicationException | The named mutex cannot be created, perhaps because a wait handle of a different type has the same name. |
ArgumentException | name is longer than 260 characters. |
Remarks
If name is not nulla null reference (Nothing in Visual Basic) and initiallyOwned is true, the calling thread owns the mutex only if the named system mutex was created as a result of this call. Since there is no mechanism for determining whether the named system mutex was created, it is better to specify false for initiallyOwned when calling this constructor. 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.
Because they are system-wide, named mutexes can be used to coordinate resource use across process boundaries.
Version Notes
Silverlight for Windows Phone
In Silverlight for Windows Phone, private object namespaces are not supported. In the .NET Framework, object namespaces are supported and because of this the backslash (\) is considered a delimiter and is not supported in the name parameter. In Silverlight for Windows Phone you can use a backslash (\) in the name parameter.
Version Information
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.