BufferBlock<T>.TryReceive(Predicate<T>, T) 方法
定义
从 IReceivableSourceBlock<TOutput> 中尝试同步接收可用输出项。Attempts to synchronously receive an available output item from the IReceivableSourceBlock<TOutput>.
public:
virtual bool TryReceive(Predicate<T> ^ filter, [Runtime::InteropServices::Out] T % item);
public bool TryReceive (Predicate<T> filter, out T item);
public bool TryReceive (Predicate<T>? filter, out T item);
abstract member TryReceive : Predicate<'T> * 'T -> bool
override this.TryReceive : Predicate<'T> * 'T -> bool
Public Function TryReceive (filter As Predicate(Of T), ByRef item As T) As Boolean
参数
- filter
- Predicate<T>
为使值得到检索,必须成功传递值的谓词。The predicate value must successfully pass in order for it to be received. filter 可能是 null ,在此情况下,所有项均将通过。filter may be null, in which case all items will pass.
- item
- T
从源中检索到的项。The item received from the source.
返回
如果可以接收项,则为 true,否则为 false。true if an item could be received; otherwise, false.
注解
此方法不会阻止等待源提供项。This method does not block waiting for the source to provide an item.
它将在检查元素后返回,而不管元素是否可用。It will return after checking for an element, whether or not an element was available.