CSharpTest.Net
SynchronizedList<T> Constructor(IList<T>)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SynchronizedList<T> Class > SynchronizedList<T> Constructor : SynchronizedList<T> Constructor(IList<T>)

storage

Glossary Item Box

Constructs a thread-safe generic collection of T, wrapped around the instance in storage using the default locking type for exclusive access, akin to placing lock(this) around each call. If you want to allow reader/writer locking provide one of those lock types from the Synchronization namespace.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal storage As IList(Of T) _
)
C# 
public SynchronizedList<T>( 
   IList<T> storage
)

Parameters

storage

Example

Library/Library.Test/TestSynchronizedCollections.cs

C#Copy Code
SynchronizedList<int> list = new SynchronizedList<int>(new List<int>(new[] { 1, 2, 3 }));
Assert.AreEqual(2, list.IndexOf(3));
Assert.AreEqual(1, list.IndexOf(2));
Assert.AreEqual(0, list.IndexOf(1));
Assert.AreEqual(-1, list.IndexOf(5));
VB.NETCopy Code
Dim list As New SynchronizedList(Of Integer)(New List(Of Integer)(New () {1, 2, 3}))
Assert.AreEqual(2, list.IndexOf(3))
Assert.AreEqual(1, list.IndexOf(2))
Assert.AreEqual(0, list.IndexOf(1))
Assert.AreEqual(-1, list.IndexOf(5))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys