Index: Include/Classes/ActiveBasic/Windows/CriticalSection.ab
===================================================================
--- Include/Classes/ActiveBasic/Windows/CriticalSection.ab	(revision 261)
+++ Include/Classes/ActiveBasic/Windows/CriticalSection.ab	(revision 261)
@@ -0,0 +1,61 @@
+'Classes/ActiveBasic/Windows/CriticalSection.ab
+
+#require <Classes/System/index.ab>
+
+Namespace ActiveBasic
+Namespace Windows
+
+Class CriticalSection
+	Inherits System.IDisposable
+Public
+	Sub CriticalSection()
+		disposed = 0
+		InitializeCriticalSection(cs)
+	End Sub
+
+	Sub ~CriticalSection()
+		Dispose()
+	End Sub
+
+	Override Sub Dispose()
+		If InterlockedIncrement(disposed) = 0 Then
+			DeleteCriticalSection(cs)
+		End If
+	End Sub
+
+	Function Enter() As CriticalSectionLock
+		Return New CriticalSectionLock(cs)
+	End Function
+Private
+	cs As CRITICAL_SECTION
+	disposed As Long
+End Class
+
+Class CriticalSectionLock
+	Inherits System.IDisposable
+Public
+	Sub CriticalSectionLock(ByRef cs As CRITICAL_SECTION)
+		pcs = VarPtr(cs)
+		EnterCriticalSection(cs)
+	End Sub
+
+	Sub ~CriticalSectionLock()
+		Dispose()
+	End Sub
+
+	Sub Leave()
+		Dispose()
+	End Sub
+
+	Override Sub Dispose()
+		Dim p = InterlockedExchangePointer(ByVal VarPtr(pcs), 0)
+		If p <> 0 Then
+			LeaveCriticalSection(ByVal p)
+		End If
+	End Sub
+Private
+	pcs As *CRITICAL_SECTION
+End Class
+
+End Namespace 'Windows
+End Namespace 'ActiveBasic
Index: Include/Classes/ActiveBasic/Windows/index.ab
===================================================================
--- Include/Classes/ActiveBasic/Windows/index.ab	(revision 261)
+++ Include/Classes/ActiveBasic/Windows/index.ab	(revision 261)
@@ -0,0 +1,3 @@
+'Classes/ActiveBasic/Windows/index.ab
+
+#require <Classes/ActiveBasic/Windows/CriticalSection.ab>
Index: Include/Classes/System/Threading/WaitHandle.ab
===================================================================
--- Include/Classes/System/Threading/WaitHandle.ab	(revision 260)
+++ Include/Classes/System/Threading/WaitHandle.ab	(revision 261)
@@ -4,6 +4,8 @@
 #define __SYSTEM_THREADING_WAITHANDLE_AB__
 
-'Namespace System
-'Namespace Threading
+#require <Classes/System/misc.ab>
+
+Namespace System
+Namespace Threading
 
 Namespace Detail
@@ -12,4 +14,5 @@
 
 Class WaitHandle
+	Inherits System.IDisposable
 Public
 	' Properties
@@ -28,16 +31,23 @@
 
 	Virtual Sub ~WaitHandle()
-		CloseHandle(h)
+		Dispose()
 	End Sub
 
 	Virtual Sub Close()
-		CloseHandle(h)
+		Dispose()
 	End Sub
 
-	Function WaitOne() As BOOL
+	Override Sub Dispose()
+		Dim hDisposing = InterlockedExchangePointer(h, 0)
+		If hDisposing <> 0 Then
+			CloseHandle(hDisposing)
+		End If
+	End Sub
+
+	Function WaitOne() As Boolean
 		Return WaitOne(INFINITE, FALSE)
 	End Function
 
-	Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As BOOL
+	Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As Boolean
 		Return WaitHandle.AfterWait(WaitForSingleObject(h, millisecondsTimeout As DWord), 1)
 	End Function
@@ -65,10 +75,10 @@
 '	Static Function WaitAny(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
 */
-	Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle) As BOOL
+	Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle) As Boolean
 		Return SignalAndWait(toSignal, toWaitOn, INFINITE, FALSE)
 	End Function
 
 Public
-	Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
+	Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As Boolean
 		Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As Detail.PFNSignalObjectAndWait
 		If pSignalObjectAndWait = 0 Then
@@ -92,8 +102,8 @@
 	h As HANDLE
 
-	Static Function AfterWait(ret As DWord, n As DWord) As BOOL
+	Static Function AfterWait(ret As DWord, n As DWord) As Boolean
 		Select Case ret
 			Case WAIT_TIMEOUT
-				Return FALSE
+				Return False
 			Case WAIT_ABANDONED
 				' Throw AbandonedMutexException
@@ -103,5 +113,5 @@
 			Case Else
 				If WAIT_OBJECT_0 <= ret And ret < WAIT_OBJECT_0 + n Then
-					Return TRUE
+					Return True
 				End If
 				' ObjectDisposedException?
@@ -112,6 +122,6 @@
 End Class
 
-'End Namespace 'Threading
-'End Namespace 'System
+End Namespace 'Threading
+End Namespace 'System
 
 #endif '__SYSTEM_THREADING_WAITHANDLE_AB__
Index: Include/Classes/System/misc.ab
===================================================================
--- Include/Classes/System/misc.ab	(revision 260)
+++ Include/Classes/System/misc.ab	(revision 261)
@@ -4,25 +4,29 @@
 #define __SYSTEM_MISC_AB__
 
-#require <Classes/System/Threading/WaitHandle.ab>
+'#require <Classes/System/Threading/WaitHandle.ab>
 
-Interface IObject
-End Interface
+Namespace System
 
 Interface IAsyncResult
 	' Properties
-	Function AsyncState() As *IObject
-	Function AsyncWaitHandle() As WaitHandle
-	Function CompletedSynchronously() As BOOL
-	Function IsCompleted() As BOOL
+	Function AsyncState() As Object
+	Function AsyncWaitHandle() As System.Threading.WaitHandle
+	Function CompletedSynchronously() As Boolean
+	Function IsCompleted() As Boolean
 End Interface
 
 Interface IClonable
 	' Method
-	Function Clone() As *IObject
+	Function Clone() As Object
 End Interface
 
 Interface IComparable
 	' Method
-	Function CompareTo(ByRef obj As IObject) As Long
+	Function CompareTo(obj As Object) As Long
+End Interface
+
+Interface IDisposable
+	' Method
+	Sub Dispose()
 End Interface
 
@@ -32,3 +36,6 @@
 End Class
 
+End Namespace 'System
+#require <Classes/System/Threading/WaitHandle.ab>
+
 #endif '__SYSTEM_MISC_AB__
