SynchronizedList
Represents a thread-safe list that supports range operations and notification events.
Herda de: SynchronizedCollection<T, List<T>>
Implementa: INotifyListEx<T>, INotifyList<T>, INotifyCollection<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList<T>, IListEx<T>, ICollectionEx<T>
Construtores
public SynchronizedList(int capacity)
synchronizedList = SynchronizedList(capacity)
Represents a thread-safe list that supports range operations and notification events.
public SynchronizedList()
synchronizedList = SynchronizedList()
Initializes a new instance of the SynchronizedList class with default capacity.
Métodos
public void AddRange(IEnumerable<T> items)
synchronizedList.AddRange(items)
Adds a range of items to the list in a thread-safe manner.
- items
- The items to add.
public IEnumerable<T> GetRange(int index, int count)
result = synchronizedList.GetRange(index, count)
Retrieves a range of items from the list starting at the specified index, in a thread-safe manner.
- index
- The zero-based starting index of the range to retrieve.
- count
- The number of items to retrieve.
Retorna: An enumerable containing the specified range of items.
protected override void OnAdded(T item)
synchronizedList.OnAdded(item)
Called after an item is added to the list, raising the AddedRange event.
- item
- The item that was added.
protected override T OnGetItem(int index)
result = synchronizedList.OnGetItem(index)
Retrieves an item at the specified index from the inner list.
- index
- The zero-based index of the item to retrieve.
Retorna: The item at the specified index.
protected override int OnIndexOf(T item)
result = synchronizedList.OnIndexOf(item)
Returns the index of the specified item in the inner list.
- item
- The item to locate.
Retorna: The zero-based index of the item, or -1 if not found.
protected override void OnInsert(int index, T item)
synchronizedList.OnInsert(index, item)
Inserts an item into the inner list at the specified index.
- index
- The zero-based index at which to insert the item.
- item
- The item to insert.
protected override void OnRemoveAt(int index)
synchronizedList.OnRemoveAt(index)
Removes an item from the inner list at the specified index.
- index
- The zero-based index of the item to remove.
protected override void OnRemoved(T item)
synchronizedList.OnRemoved(item)
Called after an item is removed from the list, raising the RemovedRange event.
- item
- The item that was removed.
public void RemoveRange(IEnumerable<T> items)
synchronizedList.RemoveRange(items)
Removes a range of items from the list in a thread-safe manner.
- items
- The items to remove.
public int RemoveRange(int index, int count)
result = synchronizedList.RemoveRange(index, count)
Removes a range of items from the list starting at the specified index, in a thread-safe manner.
- index
- The zero-based starting index of the range to remove.
- count
- The number of items to remove.
Retorna: The number of items actually removed.
Eventos
public event Action<IEnumerable<T>> AddedRange
synchronizedList.AddedRange += handler
Occurs when a range of items is added to the list.
public event Action<IEnumerable<T>> RemovedRange
synchronizedList.RemovedRange += handler
Occurs when a range of items is removed from the list.