示例#1
0
            public void Execute()
            {
                crc = 0;
                while (true)
                {
                    NeedData.WaitOne();

                    cursor = (cursor + 1) % 2;

                    if (buf[cursor] == null)
                    {
                        buf[cursor] = new byte[bufsize];
                    }

                    BytesRead = fs.Read(buf[cursor], 0, bufsize);

                    HaveData.Set();

                    if (BytesRead == 0)
                    {
                        fs.Close();
                        return;
                    }

                    crc = Crc32C.Crc32CAlgorithm.Append(crc, buf[cursor], 0, BytesRead);
                }
            }
示例#2
0
            public void Execute()
            {
                Crc = 0;
                while (true)
                {
                    NeedData.WaitOne();

                    if (cancel)
                    {
                        return;
                    }

                    _cursor = (_cursor + 1) % 2;

                    if (buf[_cursor] == null)
                    {
                        buf[_cursor] = new byte[Bufsize];
                    }

                    _bytesRead = fs.Read(buf[_cursor], 0, Bufsize);

                    HaveData.Set();

                    if (_bytesRead == 0)
                    {
                        fs.Close();
                        return;
                    }

                    Crc = Crc32C.Crc32CAlgorithm.Append(Crc, buf[_cursor], 0, _bytesRead);
                }
            }
示例#3
0
            public byte[] WaitForReadData(out int bytesread)
            {
                HaveData.WaitOne();
                bytesread = _bytesRead;
                var c = _cursor;

                NeedData.Set();
                return(buf[c]);
            }