Calls the provided delegate inside lock with the current count value
Syntax
Exceptions
Exception | Description |
System.TimeoutException | The 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.NET | Copy 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