Beispiel #1
0
 public static uint MoveStreamWithCrc32(Stream src, Stream dest, int length, uint crc)
 {
     byte[] buffer = new byte[0x8000];
     while (length > 0)
     {
         int count = src.Read(buffer, 0, Math.Min(buffer.Length, length));
         if (count == 0)
         {
             break;
         }
         crc = CheckSum.ComputeHash2(buffer, 0, count, crc);
         dest.Write(buffer, 0, count);
         length -= count;
     }
     return(crc);
 }
Beispiel #2
0
            private void CallBack(IAsyncResult ir)
            {
                byte[] buffer = (byte[])ir.AsyncState;
                int    count  = fs.EndRead(ir);

                this.length -= count;
                bool doEnd = this.length <= 0;

                this.evCallBack.WaitOne();
                if (!doEnd)
                {
                    byte[] nextBuffer = buffer == buffer1 ? buffer2 : buffer1;
                    Begin(nextBuffer);
                }
                this.crc = CheckSum.ComputeHash(buffer, 0, count, this.crc);
                this.evCallBack.Set();

                if (doEnd)
                {
                    this.End();
                }
            }