SynchronizedQueue
Provides a thread-safe queue based on the QueueEx collection.
继承自: SynchronizedCollection<T, QueueEx<T>>
构造函数
public SynchronizedQueue()
synchronizedQueue = SynchronizedQueue()
Initializes a new instance of the SynchronizedQueue class.
方法
public T Dequeue()
result = synchronizedQueue.Dequeue()
Removes and returns the item at the beginning of the queue in a thread-safe manner.
返回值: The item that was removed from the queue.
public void Enqueue(T item)
synchronizedQueue.Enqueue(item)
Adds an item to the queue in a thread-safe manner.
- item
- The item to enqueue.
protected override T OnGetItem(int index)
result = synchronizedQueue.OnGetItem(index)
Throws a NotSupportedException as this operation is not supported for a queue.
- index
- The index of the item to retrieve.
返回值: This method always throws an exception.
protected override int OnIndexOf(T item)
result = synchronizedQueue.OnIndexOf(item)
Throws a NotSupportedException as this operation is not supported for a queue.
- item
- The item to locate in the queue.
返回值: This method always throws an exception.
protected override void OnInsert(int index, T item)
synchronizedQueue.OnInsert(index, item)
Throws a NotSupportedException as this operation is not supported for a queue.
- index
- The index at which the item should be inserted.
- item
- The item to insert.
protected override void OnRemoveAt(int index)
synchronizedQueue.OnRemoveAt(index)
Throws a NotSupportedException as this operation is not supported for a queue.
- index
- The index of the item to remove.
public T Peek()
result = synchronizedQueue.Peek()
Returns the item at the beginning of the queue without removing it, in a thread-safe manner.
返回值: The item at the beginning of the queue.