MultiThreading in Queue
how to work on queue enqueue & dequeue process sysmultaneously in different thread in C#.NET
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj GogoiPosted Jun 17, 2011, 3:58 AM
An instance member is not guaranteed to be thread safe. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization
You refer this link
http://msdn.microsoft.com/en-us/magazine/ee412257.aspx
You can try the ConcurrentQueue(Of T). Here is a link
http://msdn.microsoft.com/en-us/library/dd267265.aspx
Hope this helps
Thank you
VulpesPosted Jun 16, 2011, 2:36 PM
Only reading the queue (i.e. the Peek method) is threadsafe and even then you have to ensure the Queue is not modified in the meantime.