[Serializable] public class ConcurrentList<T> : ConcurrentBag<T> //where T : ICloneable { private object lockObject = new object(); public ConcurrentList<T> CloneOnlyList() { lock (lockObject) { ConcurrentList<T> clone = new ConcurrentList<T>(); foreach (T t in this) { clone.Add(t); } return clone; } } public T this[int i] { get { return this.ElementAt(i); } } public void Clear() { T someItem; lock (lockObject) { while (!this.IsEmpty) { this.TryTake(out someItem); } } } }
No comments:
Post a Comment