Changeset 261 for Include/Classes/System/Threading/WaitHandle.ab
- Timestamp:
- May 26, 2007, 1:08:15 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Threading/WaitHandle.ab
r258 r261 4 4 #define __SYSTEM_THREADING_WAITHANDLE_AB__ 5 5 6 'Namespace System 7 'Namespace Threading 6 #require <Classes/System/misc.ab> 7 8 Namespace System 9 Namespace Threading 8 10 9 11 Namespace Detail … … 12 14 13 15 Class WaitHandle 16 Inherits System.IDisposable 14 17 Public 15 18 ' Properties … … 28 31 29 32 Virtual Sub ~WaitHandle() 30 CloseHandle(h)33 Dispose() 31 34 End Sub 32 35 33 36 Virtual Sub Close() 34 CloseHandle(h)37 Dispose() 35 38 End Sub 36 39 37 Function WaitOne() As BOOL 40 Override Sub Dispose() 41 Dim hDisposing = InterlockedExchangePointer(h, 0) 42 If hDisposing <> 0 Then 43 CloseHandle(hDisposing) 44 End If 45 End Sub 46 47 Function WaitOne() As Boolean 38 48 Return WaitOne(INFINITE, FALSE) 39 49 End Function 40 50 41 Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As B OOL51 Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As Boolean 42 52 Return WaitHandle.AfterWait(WaitForSingleObject(h, millisecondsTimeout As DWord), 1) 43 53 End Function … … 65 75 ' Static Function WaitAny(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 66 76 */ 67 Static Function SignalAndWait( ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle) As BOOL77 Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle) As Boolean 68 78 Return SignalAndWait(toSignal, toWaitOn, INFINITE, FALSE) 69 79 End Function 70 80 71 81 Public 72 Static Function SignalAndWait( ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL82 Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As Boolean 73 83 Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As Detail.PFNSignalObjectAndWait 74 84 If pSignalObjectAndWait = 0 Then … … 92 102 h As HANDLE 93 103 94 Static Function AfterWait(ret As DWord, n As DWord) As B OOL104 Static Function AfterWait(ret As DWord, n As DWord) As Boolean 95 105 Select Case ret 96 106 Case WAIT_TIMEOUT 97 Return F ALSE107 Return False 98 108 Case WAIT_ABANDONED 99 109 ' Throw AbandonedMutexException … … 103 113 Case Else 104 114 If WAIT_OBJECT_0 <= ret And ret < WAIT_OBJECT_0 + n Then 105 Return T RUE115 Return True 106 116 End If 107 117 ' ObjectDisposedException? … … 112 122 End Class 113 123 114 'End Namespace 'Threading115 'End Namespace 'System124 End Namespace 'Threading 125 End Namespace 'System 116 126 117 127 #endif '__SYSTEM_THREADING_WAITHANDLE_AB__
Note:
See TracChangeset
for help on using the changeset viewer.