Changeset 47 for Include/Classes
- Timestamp:
- Jan 7, 2007, 12:46:26 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Threading/WaitHandle.ab
r46 r47 25 25 End Sub 26 26 27 Sub WaitOne()28 WaitOne(INFINITE, FALSE)29 End Sub27 Function WaitOne() As BOOL 28 Return WaitOne(INFINITE, FALSE) 29 End Function 30 30 31 Sub WaitOne(millisecondsTimeout As Long, exitContext As BOOL)32 WaitHandle.ExitThreadIfWaitIsFailed(WaitForSingleObject(h, millisecondsTimeout As DWord))33 End Sub31 Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As BOOL 32 Return WaitHandle.AfterWait(WaitForSingleObject(h, millisecondsTimeout As DWord), 1) 33 End Function 34 34 35 ' Sub WaitOne(timeout As TimeSpan, exitContext As BOOL)35 ' Function WaitOne(timeout As TimeSpan, exitContext As BOOL) As BOOL 36 36 /* 37 Static Sub WaitAll(count As DWord, handles As *HANDLE)38 WaitAll(count, handles, INFINITE, FALSE)39 End Sub37 Static Function WaitAll(count As DWord, handles As *HANDLE) As BOOL 38 Return WaitAll(count, handles, INFINITE, FALSE) 39 End Function 40 40 41 Static Sub WaitAll(count As DWord, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL)42 WaitHandle.ExitThreadIfWaitIsFailed(WaitForMultipleObjects(count, handles, TRUE, millisecondsTimeout))43 End Sub41 Static Function WaitAll(count As DWord, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 42 Return WaitHandle.AfterWait(WaitForMultipleObjects(count, handles, TRUE, millisecondsTimeout), count) 43 End Function 44 44 45 ' Static Sub WaitAll(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL)45 ' Static Function WaitAll(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 46 46 47 Static Sub WaitAny(count As DWord, handles As *HANDLE)48 WaitAny(count, handles, INFINITE, FALSE)49 End Sub47 Static Function WaitAny(count As DWord, handles As *HANDLE) As BOOL 48 Return WaitAny(count, handles, INFINITE, FALSE) 49 End Function 50 50 51 Static Sub WaitAny(count As DWord, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL)52 WaitHandle.ExitThreadIfWaitIsFailed(WaitForMultipleObjects(count, handles, FALSE, millisecondsTimeout))53 End Sub51 Static Function WaitAny(count As DWord, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 52 Return WaitHandle.AfterWait(WaitForMultipleObjects(count, handles, FALSE, millisecondsTimeout), count) 53 End Function 54 54 55 ' Static Sub WaitAny(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL)55 ' Static Function WaitAny(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 56 56 */ 57 Static Sub SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle)58 SignalAndWait(toSignal, toWaitOn, INFINITE, FALSE)59 End Sub57 Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle) As BOOL 58 Return SignalAndWait(toSignal, toWaitOn, INFINITE, FALSE) 59 End Function 60 60 61 Static Sub SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL)61 Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 62 62 Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") _ 63 63 As *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord … … 67 67 ExitThread(0) 68 68 End If 69 ExitThreadIfWaitIsFailed(pSignalAndWait(toSignal.Handle, toWaitOn.Handle, millisecondsTimeout As DWord))70 End Sub69 Return AfterWait(pSignalAndWait(toSignal.Handle, toWaitOn.Handle, millisecondsTimeout As DWord), 1) 70 End Function 71 71 72 ' Static Sub SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, timeout As TimeSpan, exitContext As BOOL)72 ' Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, timeout As TimeSpan, exitContext As BOOL) As BOOL 73 73 74 74 ' Protected … … 82 82 h As HANDLE 83 83 84 Static Sub ExitThreadIfWaitIsFailed(ret As DWord)84 Static Function AfterWait(ret As DWord, n As DWord) As BOOL 85 85 Select Case ret 86 Case WAIT_OBJECT_087 Exit Sub88 86 Case WAIT_TIMEOUT 89 Exit Sub87 Return FALSE 90 88 Case WAIT_ABANDONED 91 89 ' Throw AbandonedMutexException … … 94 92 'Case WAIT_FAILED 95 93 Case Else 94 If WAIT_OBJECT_0 <= ret And ret < WAIT_OBJECT_0 + n Then 95 Return TRUE 96 End If 96 97 ' ObjectDisposedException? 97 98 Debug
Note:
See TracChangeset
for help on using the changeset viewer.