Was sind die Unterschiede zwischen ConcurrentQueue und BlockingCollection in .Net?

Was sind die Unterschiede zwischenConcurrentQueue undBlockingCollection in .Net?

WarumBlockingCollection ist am besten für den Produzent-Verbraucher-Betrieb geeignet, wenn dies durchführbar istConcurrentQueue? Muss ich im folgenden Code etwas verbessern?

<code>MessageSlotMachineGameStartOrAndStatusUpdate msg;

while (!aCancellationToken.IsCancellationRequested)
{
    try
    {
        this.isStillConsumingMsg = true;
        Boolean takeResult = this.msgQueue.TryTake(out msg, this.msgConsumeTimeOut, aCancellationToken);
        if (takeResult)
        {
            if (msg != null)
            {
                this.ProcessMessage(msg);
            }
        }
        else
        {
            break;
        }
    }
    catch (OperationCanceledException err)
    {
        EngineManager.AddExceptionLog(err, "Signal Operation Canceled");
    }
    catch (Exception err)
    {
        EngineManager.AddExceptionLog(err, "Signal exception");
    }
    finally
    {
        this.isStillConsumingMsg = false;
    }
}
</code>

Antworten auf die Frage(1)

Ihre Antwort auf die Frage