SynchronizedCollection<T> Class

Definition

Provides a thread-safe collection that contains objects of a type specified by the generic parameter as elements.

generic <typename T>
public ref class SynchronizedCollection : System::Collections::Generic::ICollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IList<T>, System::Collections::IList
[System.Runtime.InteropServices.ComVisible(false)]
public class SynchronizedCollection<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.IList
type SynchronizedCollection<'T> = class
    interface IList<'T>
    interface ICollection<'T>
    interface seq<'T>
    interface IList
    interface ICollection
    interface IEnumerable
Public Class SynchronizedCollection(Of T)
Implements ICollection(Of T), IEnumerable(Of T), IList, IList(Of T)

Type Parameters

T

The type of object contained as items in the thread-safe collection.

Inheritance
SynchronizedCollection<T>
Derived
Attributes
Implements

Remarks

The SynchronizedCollection<T> stores data in a List<T> container and provides an object that can be set and used to synchronize access to the collection so that it is thread-safe. The IList<T> container can be recovered using the Items method. The synchronized object can be recovered using the SyncRoot property. It can only be set using one of the constructors that take the syncRoot parameter.

Constructors

SynchronizedCollection<T>()

Initializes a new instance of the SynchronizedCollection<T> class.

SynchronizedCollection<T>(Object)

Initializes a new instance of the SynchronizedCollection<T> class with the object used to synchronize access to the thread-safe collection.

SynchronizedCollection<T>(Object, IEnumerable<T>)

Initializes a new instance of the SynchronizedCollection<T> class from a specified enumerable list of elements and with the object used to synchronize access to the thread-safe collection.

SynchronizedCollection<T>(Object, List<T>, Boolean)
SynchronizedCollection<T>(Object, T[])

Initializes a new instance of the SynchronizedCollection<T> class from a specified array of elements and with the object used to synchronize access to the thread-safe collection.

Properties

Count

Gets the number of elements contained in the thread-safe collection.

Item[Int32]

Gets an element from the thread-safe collection with a specified index.

Items

Gets the list of elements contained in the thread-safe collection.

SyncRoot

Gets the object used to synchronize access to the thread-safe collection.

Methods

Add(T)

Adds an item to the thread-safe, read-only collection.

Clear()

Removes all items from the collection.

ClearItems()

Removes all items from the collection.

Contains(T)

Determines whether the collection contains an element with a specific value.

CopyTo(T[], Int32)

Copies the elements of the collection to a specified array, starting at a particular index.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Returns an enumerator that iterates through the synchronized collection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IndexOf(T)

Returns the index of the first occurrence of a value in the collection.

Insert(Int32, T)

Inserts an item into the collection at a specified index.

InsertItem(Int32, T)

Inserts an item into the collection at a specified index.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(T)

Removes the first occurrence of a specified item from the collection.

RemoveAt(Int32)

Removes an item at a specified index from the collection.

RemoveItem(Int32)

Removes an item at a specified index from the collection.

SetItem(Int32, T)

Replaces the item at a specified index with another item.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ICollection.CopyTo(Array, Int32)

Copies the elements of the collection to a specified array, starting at a particular index.

ICollection.IsSynchronized

Gets a value that indicates whether the collection is thread safe.

ICollection.SyncRoot

Gets the object used to synchronize access to the thread-safe collection.

ICollection<T>.IsReadOnly

Gets a value that indicates whether the collection is read only.

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through the synchronized collection.

IList.Add(Object)

Adds an element to the collection.

IList.Contains(Object)

Determines whether the collection contains an element with a specific value.

IList.IndexOf(Object)

Determines the zero-based index of an element in the collection.

IList.Insert(Int32, Object)

Inserts an object into the collection at a specified index.

IList.IsFixedSize

Gets a value that indicates whether the collection is fixed in size.

IList.IsReadOnly

Gets a value that indicates whether the collection is read only.

IList.Item[Int32]

Gets or sets the item at a specified zero-based index.

IList.Remove(Object)

Removes the first occurrence of a specified object as an element from the collection.

Extension Methods

CopyToDataTable<T>(IEnumerable<T>)

Returns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

Copies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the ancestors of every node in the source collection. Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

Returns a filtered collection of the child elements of every element and document in the source collection. Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

Removes every node in the source collection from its parent node.

Applies to