ConcurrentQueue<T>.IProducerConsumerCollection<T>.TryTake(T) 方法

定义

尝试从 IProducerConsumerCollection<T> 中移除和返回一个对象。Attempts to remove and return an object from the IProducerConsumerCollection<T>.

 virtual bool System.Collections.Concurrent.IProducerConsumerCollection<T>.TryTake([Runtime::InteropServices::Out] T % item) = System::Collections::Concurrent::IProducerConsumerCollection<T>::TryTake;
bool IProducerConsumerCollection<T>.TryTake (out T item);
Function TryTake (ByRef item As T) As Boolean Implements IProducerConsumerCollection(Of T).TryTake

参数

item
T

此方法返回时,如果操作成功,则 item 包含所移除的对象。When this method returns, if the operation was successful, item contains the object removed. 如果没有可供移除的对象,则不指定该值。If no object was available to be removed, the value is unspecified.

返回

如果成功删除并返回了元素,则为 true;否则为 falsetrue if an element was removed and returned successfully; otherwise, false.

实现

注解

对于 ConcurrentQueue<T>,此操作将尝试从 @no__t 的开头删除对象。For ConcurrentQueue<T>, this operation will attempt to remove the object from the beginning of the ConcurrentQueue<T>.

适用于

另请参阅