ConcurrentBag<T>.TryTake(T) 方法

定义

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

public:
 virtual bool TryTake([Runtime::InteropServices::Out] T % result);
public bool TryTake (out T result);
abstract member TryTake : 'T -> bool
override this.TryTake : 'T -> bool
Public Function TryTake (ByRef result As T) As Boolean

参数

result
T

此方法返回时,result 包含从 ConcurrentBag<T> 中移除的对象;如果包为空,则返回 T 的默认值。When this method returns, result contains the object removed from the ConcurrentBag<T> or the default value of T if the bag is empty.

返回

如果已成功移除对象,则为 true;否则为 falsetrue if an object was removed successfully; otherwise, false.

实现

适用于

另请参阅