CSharpTest.Net
ObjectKeepAlive Constructor(Int32,Int32,TimeSpan)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class > ObjectKeepAlive Constructor : ObjectKeepAlive Constructor(Int32,Int32,TimeSpan)

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max

Glossary Item Box

Configures the keep-alive policy for this container

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal minItems As Integer, _
   ByVal maxItems As Integer, _
   ByVal maxAge As TimeSpan _
)
C# 
public ObjectKeepAlive( 
   int minItems,
   int maxItems,
   TimeSpan maxAge
)

Parameters

minItems
The minimum number of items desired in the list (kept event after age expires)
maxItems
The maximum number of items desired in the list (discarded even if age has not expired)
maxAge
Determines how long to keep an object if the count is between min and max

Example

Library/Library.Test/TestObjectKeepAlive.cs

C#Copy Code
TimeSpan timeout = TimeSpan.FromMilliseconds(25);
ObjectKeepAlive keep = new ObjectKeepAlive(100, 10000, timeout);

for (int i = 0; i < 100000; i++)
    keep.Add(i);

System.Threading.Thread.Sleep(timeout);

for (int i = 0; i < 10000; i++)
    keep.Add(i);
VB.NETCopy Code
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(25)
Dim keep As New ObjectKeepAlive(100, 10000, timeout)

Dim i As Integer = 0
While i < 100000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

System.Threading.Thread.Sleep(timeout)

Dim i As Integer = 0
While i < 10000
    keep.Add(i)
    System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys