generics - What is the difference between concurrent queue and blockingcollection in. Net?
What are the differences between ConcurrentQueue
and BlockingCollection
in .Net?
Why BlockingCollection
is best for producer-consumer operation when it can be done through ConcurrentQueue
? Do I have to improve anything in the following 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;
}
}
This question and all comments follow the
"Attribution Required."
Similar questions
- What is the difference between "&" and "," in Java generics?
- What is the difference between "e", "t" and "? Java generics?
- c# - Concurrent priority queue in. Net 4.0
- .net - Outbound object from concurrent queue in C
- collections - Java, concurrent linked deque and concurrent linked queue - what's the difference?
- More similar questions >>
All Answers
Leave a Reply