ConcurrentQueue<T>.TryPeek(T) ConcurrentQueue<T>.TryPeek(T) ConcurrentQueue<T>.TryPeek(T) ConcurrentQueue<T>.TryPeek(T) Method

定義

嘗試傳回在 ConcurrentQueue<T> 前端的物件,但不將它移除。Tries to return an object from the beginning of the ConcurrentQueue<T> without removing it.

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

參數

result
T T T T

如果這個方法傳回,則 result 會包含來自 ConcurrentQueue<T> 前端的物件,如果作業失敗,則傳回非指定的值。When this method returns, result contains an object from the beginning of the ConcurrentQueue<T> or an unspecified value if the operation failed.

傳回

如果成功傳回物件則為 true,否則為 falsetrue if an object was returned successfully; otherwise, false.

備註

若要判斷集合是否包含任何專案, 建議使用IsEmpty屬性, 而不是查看。For determining whether the collection contains any items, use of the IsEmpty property is recommended rather than peeking.

適用於

另請參閱