Visual Basic (Declaration) | |
---|---|
Public Function New( _ ByVal captureStack As Boolean, _ ByVal limitTimeout As Integer, _ ByVal limitNestedReaders As Integer, _ ByVal concurrentReads As Boolean, _ ByVal limitNestedWriters As Integer _ ) |
C# | |
---|---|
public DebugLockFactory<T>( bool captureStack, int limitTimeout, int limitNestedReaders, bool concurrentReads, int limitNestedWriters ) |
Parameters
- captureStack
- limitTimeout
- limitNestedReaders
- concurrentReads
- limitNestedWriters
Library/Library.Test/LockingTests/TestDebugLocking.cs
C# | Copy Code |
---|---|
DebugLockFactory<SimpleReadWriteLocking> factory = new DebugLockFactory<SimpleReadWriteLocking>( false, 0, 1, false, 1); using (ILockStrategy lck = factory.Create()) { using (lck.Write()) using (lck.Write()) //second lock, allow recurse 1 time as per constructor { try { using (lck.Write()) { Assert.Fail(); } } catch (Exception ex) { Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock } } using (lck.Read()) using (lck.Read()) //second lock, allow recurse 1 time as per constructor { try { using (lck.Read()) { Assert.Fail(); } } catch (Exception ex) { Assert.IsTrue(ex is DebugAssertionFailedException);//nesting prohibited by debug lock } } } |
VB.NET | Copy Code |
---|---|
Dim factory As New DebugLockFactory(Of SimpleReadWriteLocking)(False, 0, 1, False, 1) Using lck As ILockStrategy = factory.Create() Using lck.Write() Using lck.Write() 'second lock, allow recurse 1 time as per constructor Try Using lck.Write() Assert.Fail() End Using Catch ex As Exception 'nesting prohibited by debug lock Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException) End Try End Using End Using Using lck.Read() Using lck.Read() 'second lock, allow recurse 1 time as per constructor Try Using lck.Read() Assert.Fail() End Using Catch ex As Exception 'nesting prohibited by debug lock Assert.IsTrue(TypeOf ex Is DebugAssertionFailedException) End Try End Using End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7