CSharpTest.Net
Write() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Synchronization Namespace > DebugLocking Class > Write Method : Write() Method

Glossary Item Box

Returns a read and write lock

Syntax

Visual Basic (Declaration) 
Public Overloads Function Write() As WriteLock
C# 
public WriteLock Write()

Example

Library/Library.Test/LockingTests/TestDebugLocking.cs

C#Copy Code
using (DebugLocking<SimpleReadWriteLocking> l = new DebugLocking<SimpleReadWriteLocking>(
    false, 0, 1, false, 1))
{
    Assert.IsFalse(l.CaptureStack);

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(0, l.MaxWriterCount);

    using (l.Write())
    {
        Assert.AreEqual(1, l.CurrentWriterCount);
        Assert.AreEqual(1, l.LocalWriterCount);
        using (l.Write(0))
        {
            Assert.AreEqual(2, l.CurrentWriterCount);
            Assert.AreEqual(2, l.LocalWriterCount);
        }
    }

    Assert.AreEqual(0, l.CurrentWriterCount);
    Assert.AreEqual(0, l.LocalWriterCount);
    Assert.AreEqual(2, l.MaxWriterCount);
}
VB.NETCopy Code
Using l As New DebugLocking(Of SimpleReadWriteLocking)(False, 0, 1, False, 1)
    Assert.IsFalse(l.CaptureStack)

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(0, l.MaxWriterCount)

    Using l.Write()
        Assert.AreEqual(1, l.CurrentWriterCount)
        Assert.AreEqual(1, l.LocalWriterCount)
        Using l.Write(0)
            Assert.AreEqual(2, l.CurrentWriterCount)
            Assert.AreEqual(2, l.LocalWriterCount)
        End Using
    End Using

    Assert.AreEqual(0, l.CurrentWriterCount)
    Assert.AreEqual(0, l.LocalWriterCount)
    Assert.AreEqual(2, l.MaxWriterCount)
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys