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

action

Glossary Item Box

Calls the provided delegate inside lock with the current count value

Syntax

Visual Basic (Declaration) 
Public Sub TotalCount( _
   ByVal action As Action(Of Integer) _
) 
C# 
public void TotalCount( 
   Action<int> action
)

Parameters

action

Exceptions

ExceptionDescription
System.TimeoutExceptionThe exception that is thrown when the time allotted for a process or operation has expired.

Example

Library/Library.Test/TestUsageCounter.cs

C#Copy Code
using (UsageCounter counter = new UsageCounter("some global name"))
{
    using (UsageCounter counter2 = new UsageCounter("some global name"))
        counter2.Increment();
    counter.TotalCount(delegate(int count) { Assert.AreEqual(1, count); });

    using (UsageCounter counter2 = new UsageCounter("some global name"))
    {
        counter2.TotalCount(delegate(int count) { Assert.AreEqual(1, count); });
        counter2.Decrement();
    }
    counter.TotalCount(delegate(int count) { Assert.AreEqual(0, count); });
}
VB.NETCopy Code
Using counter As New UsageCounter("some global name")
    Using counter2 As New UsageCounter("some global name")
        counter2.Increment()
    End Using
    counter.TotalCount(Function(count As Integer) Do
        Assert.AreEqual(1, count)
    End Function)

    Using counter2 As New UsageCounter("some global name")
        counter2.TotalCount(Function(count As Integer) Do
            Assert.AreEqual(1, count)
        End Function)
        counter2.Decrement()
    End Using
    counter.TotalCount(Function(count As Integer) Do
        Assert.AreEqual(0, count)
    End Function)
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