ConcurrentStack<T>.IProducerConsumerCollection<T>.TryTake Method (T)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Attempts to remove and return an object from the System.Collections.Concurrent.IProducerConsumerCollection<T>.

Namespace:   System.Collections.Concurrent
Assembly:  mscorlib (in mscorlib.dll)

bool IProducerConsumerCollection<T>.TryTake(
	out T item


Type: T

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.

Return Value

Type: System.Boolean

true if an element was removed and returned succesfully; otherwise, false.

For ConcurrentStack<T>, this operation will attempt to pop the object at the top of the ConcurrentStack<T>.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top