public void EnqueueForCompressing(byte[] buffer) { lock (locker) { if (isDead) { throw new InvalidOperationException("Queue already stopped"); } ByteBlock _block = new ByteBlock(blockId, buffer); queue.Enqueue(_block); blockId++; Monitor.PulseAll(locker); } }
public void EnqueueForWriting(ByteBlock _block) { int id = _block.ID; lock (locker) { if (isDead) { throw new InvalidOperationException("Queue already stopped"); } while (id != blockId) { Monitor.Wait(locker); } queue.Enqueue(_block); blockId++; Monitor.PulseAll(locker); } }