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