/// <summary> /// Creates a new instance of <see cref="ThreadSafeList{T}"/>. /// </summary> public ThreadSafeList() { _interlocker = new InterlockHelper(); _items = _emptyArray; _capacity = 0; _locker = new object(); }
/// <summary> /// Creates a new instance of <see cref="ThreadSafeList{T}"/>, initialized to a specific capacity. /// </summary> /// <param name="initialCapacity">The initial capacity of the list.</param> public ThreadSafeList(int initialCapacity) { if (initialCapacity < 0) { throw new ArgumentOutOfRangeException("Cannot have a capacity less than 0."); } _interlocker = new InterlockHelper(); _items = new T[initialCapacity]; _capacity = _items.Length; _locker = new object(); }