[419] | 1 | ' Classes/System/Threading/Mutex.ab
|
---|
| 2 |
|
---|
| 3 | #ifndef __SYSTEM_THREADING_MUTEX_AB__
|
---|
| 4 | #define __SYSTEM_THREADING_MUTEX_AB__
|
---|
| 5 |
|
---|
| 6 | Namespace System
|
---|
| 7 | Namespace Threading
|
---|
| 8 |
|
---|
| 9 | Class Mutex
|
---|
| 10 | Inherits System.Threading.WaitHandle
|
---|
| 11 |
|
---|
| 12 | Public
|
---|
| 13 | Sub Mutex()
|
---|
| 14 | This.Handle(CreateMutex(NULL,FALSE,NULL))
|
---|
| 15 | End Sub
|
---|
| 16 | Sub Mutex(initiallyOwned As Boolean)
|
---|
| 17 | This.Handle(CreateMutex(NULL,initiallyOwned As BOOL,NULL))
|
---|
| 18 | End Sub
|
---|
| 19 | Sub Mutex(initiallyOwned As Boolean, name As String)
|
---|
| 20 | This.Handle(CreateMutex(NULL,initiallyOwned As BOOL,ToTCStr(name)))
|
---|
| 21 | End Sub
|
---|
| 22 | Sub Mutex(initiallyOwned As Boolean, name As String, ByRef createdNew As Boolean)
|
---|
| 23 | This.Handle(CreateMutex(NULL,initiallyOwned As BOOL,ToTCStr(name)))
|
---|
| 24 | If ERROR_ALREADY_EXISTS=GetLastError() Then createdNew=False Else createdNew=True
|
---|
| 25 | 'Throw UnauthorizedAccessException
|
---|
| 26 | 'Throw IOException
|
---|
| 27 | 'Throw ApplicationException
|
---|
| 28 | 'Throw ArgumentException
|
---|
| 29 | End Sub
|
---|
| 30 | /* Sub Mutex(Boolean, String, Boolean, MutexSecurity)
|
---|
| 31 | TODO
|
---|
| 32 | End Sub*/
|
---|
| 33 |
|
---|
| 34 | Static Function OpenExisting (name As String) As Mutex
|
---|
| 35 | This.Handle(OpenMutex(MUTEX_ALL_ACCESS,FALSE,ToTCStr(name)))
|
---|
| 36 | 'Throw ArgumentException
|
---|
| 37 | 'Throw ArgumentNullException
|
---|
| 38 | 'Throw WaitHandleCannotBeOpenedException
|
---|
| 39 | 'Throw IOException
|
---|
| 40 | 'Throw UnauthorizedAccessException
|
---|
| 41 | End Function
|
---|
| 42 |
|
---|
| 43 | /* Static Function OpenExisting (String, MutexRights) As Mutex
|
---|
| 44 | TODO
|
---|
| 45 | End Function*/
|
---|
| 46 |
|
---|
| 47 | Sub Release()
|
---|
| 48 | If ReleaseMutex(This.Handle()) = 0 Then
|
---|
| 49 | 'Throw ApplicationException
|
---|
| 50 | End If
|
---|
| 51 | End Sub
|
---|
| 52 |
|
---|
| 53 | End Class
|
---|
| 54 |
|
---|
| 55 | End Namespace 'Threading
|
---|
| 56 | End Namespace 'System
|
---|
| 57 |
|
---|
| 58 | #endif
|
---|