Exception class: DebugAssertionFailedException Debug Assertion Failed: {0}
Syntax
Example
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 |
Inheritance Hierarchy
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also