What is the difference between TryDequeue and TryTake in a ConcurrentQueue<>
According to available source code there is no difference as TryTake
invokes TryDequeue
/// <summary>
/// Attempts to remove and return an object from the <see cref="Concurrent.IProducerConsumerCollection{T}"/>.
/// </summary>
/// <param name="item">
/// When this method returns, if the operation was successful, <paramref name="item"/> contains the
/// object removed. If no object was available to be removed, the value is unspecified.
/// </param>
/// <returns>true if an element was removed and returned successfully; otherwise, false.</returns>
/// <remarks>For <see cref="ConcurrentQueue{T}"/>, this operation will attempt to remove the object
/// from the beginning of the <see cref="ConcurrentQueue{T}"/>.
/// </remarks>
bool IProducerConsumerCollection<T>.TryTake([MaybeNullWhen(false)] out T item) => TryDequeue(out item);
Souce: https://source.dot.net/#System.Private.CoreLib/ConcurrentQueue.cs,201
Why bother with implementing that TryDequeue method?
TryDequeue
follows expected name conventions associated with queues and is local to ConcurrentQueue<>
. As well, TryTake
follows naming convention normally associated with producer/consumer pattern.