CSharpTest.Net
Decrement() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > UsageCounter Class > Decrement Method : Decrement() Method

Glossary Item Box

Decrements the counter by one

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Decrement() 
C# 
public void Decrement()

Example

Library/Library.Test/TestUsageCounter.cs

C#Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    Assert.AreEqual(0, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Increment();
    Assert.AreEqual(2, counter.InstanceCount);
    using (UsageCounter copy = new UsageCounter("some global name"))
        Assert.AreEqual(0, copy.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(1, counter.InstanceCount);
    counter.Decrement();
    Assert.AreEqual(0, counter.InstanceCount);
}
VB.NETCopy Code
Using counter As New UsageCounter("some global name")
    Assert.AreEqual(0, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Increment()
    Assert.AreEqual(2, counter.InstanceCount)
    Using copy As New UsageCounter("some global name")
        Assert.AreEqual(0, copy.InstanceCount)
    End Using
    counter.Decrement()
    Assert.AreEqual(1, counter.InstanceCount)
    counter.Decrement()
    Assert.AreEqual(0, counter.InstanceCount)
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