CSharpTest.Net
Count Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WaitAndContinueList Class : Count Property

Glossary Item Box

Returns the number of work queue items

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Count As Integer
C# 
public int Count {get;}

Example

Library/Library.Test/TestWaitAndContinue.cs

C#Copy Code
WaitAndContinueList work = new WaitAndContinueList();
SampleWork item1, item2;
IWaitAndContinue signaled;

work.AddWork(item1 = new SampleWork());
work.AddWork(item2 = new SampleWork());

Assert.AreEqual(2, work.Count);
Assert.IsFalse(work.IsEmpty);

//normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1));
item2.Ready.Set();
Assert.IsTrue(work.PerformWork(0));
Assert.IsTrue(item2.Completed);
Assert.IsTrue(item2.Disposed);

Assert.IsFalse(work.PerformWork(1));
item1.Cancel.Set();
Assert.IsTrue(work.PerformWork(0, out signaled));
Assert.IsTrue(ReferenceEquals(signaled, item1));
Assert.IsTrue(item1.Completed);
Assert.IsTrue(item1.Cancelled);
Assert.IsTrue(item1.Disposed);

Assert.IsTrue(work.IsEmpty);
Assert.AreEqual(0, work.Count);
Assert.IsFalse(work.PerformWork(1));
VB.NETCopy Code
Dim work As New WaitAndContinueList()
Dim item1 As SampleWork, item2 As SampleWork
Dim signaled As IWaitAndContinue

work.AddWork(item1 = New SampleWork())
work.AddWork(item2 = New SampleWork())

Assert.AreEqual(2, work.Count)
Assert.IsFalse(work.IsEmpty)

'normally done as a loop: while(work.Perform(timeout)) { }
Assert.IsFalse(work.PerformWork(1))
item2.Ready.[Set]()
Assert.IsTrue(work.PerformWork(0))
Assert.IsTrue(item2.Completed)
Assert.IsTrue(item2.Disposed)

Assert.IsFalse(work.PerformWork(1))
item1.Cancel.[Set]()
Assert.IsTrue(work.PerformWork(0, signaled))
Assert.IsTrue(ReferenceEquals(signaled, item1))
Assert.IsTrue(item1.Completed)
Assert.IsTrue(item1.Cancelled)
Assert.IsTrue(item1.Disposed)

Assert.IsTrue(work.IsEmpty)
Assert.AreEqual(0, work.Count)
Assert.IsFalse(work.PerformWork(1))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys