Пример #1
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            if (count <= 0 || offset < 0 || buffer.Length <= 1 || offset > buffer.Length)
            {
                return;
            }

            try {
                ByteBufferLock.WaitOne();
                int    size      = ByteBuffer.Count;
                byte[] subBuffer = buffer.Skip(offset).Take(count).ToArray();
                ByteBuffer.AddRange(subBuffer);
                byte[] cloneBuffer = ByteBuffer.Skip(size).ToArray();
                bool   equal       = subBuffer.Length == cloneBuffer.Length;
                if (equal)
                {
                    for (int i = 0; i < subBuffer.Length; i++)
                    {
                        equal = subBuffer[i] == cloneBuffer[i];
                        if (!equal)
                        {
                            break;
                        }
                    }
                }
                string sub   = Encoding.ASCII.GetString(subBuffer);
                string clone = Encoding.ASCII.GetString(cloneBuffer);
                //ByteBuffer.AddRange(buffer, offset, count);
                InternalWritePointer += count;
                //try {
                //    OverReadLock.Release();
                //} catch { }
            } finally {
                ByteBufferLock.Release();
            }

            foreach (Stream x in ParallelWriteStreams)
            {
                x.Write(buffer, offset, count);
            }
        }