Ejemplo n.º 1
0
        private async void ExtractFanoWorker(object sender, DoWorkEventArgs e)
        {
            long progress = 0;
            var  reader   = new BufferedReader(2000000, mInputStreamFanoO);
            var  writer   = new BufferedWriter(2000000, mOutputStreamFanoO);
            var  len      = mInputStreamFanoO.Length;

            if (len == 0)
            {
                len = 1;
            }

            var extractor = new FanoEncoder(reader, writer);

            extractor.WordLength   += (x, y) => len = y / x * 8;
            extractor.WordsWritten += x =>
            {
                progress += x;
            };
            Timer t = new Timer(o => mFanoOWorker.ReportProgress(Convert.ToInt32(progress * 100 / len)), null, 0, 25);

            await extractor.Decode();

            t.Dispose();
            await writer.FlushBuffer();

            mInputStreamFanoO.Close();
            mOutputStreamFanoO.Close();
        }
Ejemplo n.º 2
0
        private async void CompressFanoWorker(object sender, DoWorkEventArgs e)
        {
            long progress = 0;
            var  reader   = new BufferedReader(2000000, mInputStreamFanoI);
            var  writer   = new BufferedWriter(2000000, mOutputStreamFanoI);
            var  len      = mInputStreamFanoI.Length / mWordLength * 8;

            if (len == 0)
            {
                len = 1;
            }

            var compressor = new FanoEncoder(reader, writer);

            compressor.WordsWritten += x =>
            {
                progress += x;
            };
            Timer t = new Timer(o => mFanoIWorker.ReportProgress(Convert.ToInt32(progress * 100 / len)), null, 0, 25);

            await compressor.Encode(mWordLength);

            t.Dispose();
            await writer.FlushBuffer();

            mInputStreamFanoI.Close();
            mOutputStreamFanoI.Close();
        }