title: Queue for multiple producers and consumers
body: <p>I have to write a communication between multiple threads (at least 3 for now) in .Net3.5 and each of them is both producer and consumer.
  Instead of sending signals between each pair of threads my idea is to implement a queue of messages which will store class like this:</p>
  
  <pre><code>enum Signals { ObjectArrivedOnLightBarrier, ObjectLeftLightBarrier, CodeFound };
  enum UnitID { GrabThread, ImageProcessingThread, SaveThread };
  
  // Consumer shows who the message is intended for (and only that unit is allowed to remove it from the queue)
  public class QueuedSignal
  {
      Signals Message;
      UnitID Producer;
      UnitID Consumer;
  }
  </code></pre>
  
  <p>The idea is that any thread can peek at the first item in the queue and leave it alone if the message is not intended for it (it is not an issue if there are few other messages and one of them might be intended for this thread).</p>
  
  <p>Is queue thread-safe when there are multiple producers and consumers.</p>