CSharpTest.Net
Add Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Utils Namespace > ObjectKeepAlive Class : Add Method

item

Glossary Item Box

Cleans up expired items and adds the object to the list of items to keep alive.

Syntax

Visual Basic (Declaration) 
Public Sub Add( _
   ByVal item As Object _
) 
C# 
public void Add( 
   object item
)

Parameters

item

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