A mutex is a synchronization primitive that can be synchronized between processes.
|
name |
description |
|
Mutex() |
Initializes a new instance of the Mutex class using the default properties. |
|
mutex (Boolean) |
mutex class with a Boolean value that indicates whether the calling thread should has initial Ownership of the mutex. " > 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. |
|
mutex (Boolean,? String) |
Mutex class with a Boolean value that indicates whether the calling thread should has initial ownership of the mutex, and A string is the name of the mutex. mutex class with a Boolean value that indicates whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex. |
|
mutex (Boolean,? String,? Boolean) |
Mutex class with a Boolean value that indicates whether the calling thread should has initial ownership of the mutex, a s Tring that's the name of the mutex, and a Boolean value, when the method returns, indicates whether the calling Thre Ad was granted initial ownership of the mutex. " You use a Boolean value that indicates whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex, and when the thread returns, a Boolean value that indicates whether the calling thread has given initial ownership of the mutex mutex class. |
|
Mutex(Boolean,? String,? Boolean,? MutexSecurity) |
Initializes a Boolean variable that can indicate whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex, and when the thread returns, indicates whether the calling thread has given the mutex initial ownership, and whether access control security has been applied to the named mutex A new instance of the Mutex class. |
code Example
When used, the WaitOne function must be paired with the ReleaseMutex function.
Inheritance HierarchySystem. Object
?? System. MarshalByRefObject
???? System.Threading. WaitHandle
?????? system.threading. Mutex the
MarshalByRefObject class allows objects to be accessed across application domain boundaries in applications that support remoting.
The mutex is more advanced than the critical section and can be named to support thread synchronization across processes. Mutexes are calls to the Win32 API for mutex operations, so different processes under the same operating system can share locks according to the name of the mutex.
Because of this, the operation of the mutex invokes system resources, and the performance is reduced relative to the critical section. It is better to use critical zone performance for in-process thread synchronization .
Reference Links:
Http://www.myexception.cn/asp-dotnet/2112687.html
http://blog.sina.com.cn/s/blog_68e4d2910100q6uj.htmlhttps://www.cnblogs.com/yinzixin/archive/2011/11/16/2250562.html
[. NET multithreading] Mutex