KeelRisk
KeelRisk

Reputation: 749

Where is ConcurrentQueue TryDequeue implementation

Where can I see the actual code that performs the heavy lifting on TryDequeue? I tried F12 (Go To Definition) but just the method name and parameters.

lock (this)
{
    T overflow;
    while (q.Count > Limit && q.TryDequeue(out overflow)) ;
}

Upvotes: 1

Views: 769

Answers (2)

Sefe
Sefe

Reputation: 14007

ConcurrentQueue is a class of the .NET framework. As such, it is available on your system as a binary in the global assembly cache. That means it comes without source code. In the title of your tab you will see the remark [from metadata], which means it is auto-generated source.

You can check the reference source online, which is provided by Microsoft. You can also use a decompiler like ILSpy or reflector.

Upvotes: 1

Cory Nelson
Cory Nelson

Reputation: 30001

You can view the reference source. Highly recommend not locking around a ConcurrentQueue, it defeats the purpose. A Queue will be much faster in that case.

Upvotes: 1

Related Questions