Example #1
0
        static void Exect(Stream read
                          , Stream write
                          , ReadWriteManager manager
                          , System.IO.Compression.CompressionMode mode
                          , int?readBufferSize, int tCount)
        {
            manager.CreateThreadPool(
                tCount
                , () => read.BeginRead(
                    manager.GetReadExectContext(
                        block => write.BeginWrite(
                            block.GZip(mode)
                            , manager.GetWriteExectContext()))
                    , readBufferSize))
            .ForEach(t => t.Start());

            long res = 0, old = 0;

            while (!manager.WaitOne(100))
            {
                if (old < (res = (100 * read.Position) / read.Length))
                {
                    Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " Прогресс: " + (old = res) + "%");
                }
            }

            manager.IsExceptionHappened();

            Console.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " Завершено за " + manager.TotalTime().ToString());
        }
Example #2
0
 public bool OnWillStart(long id) => id > 0 && !_readWriteManager.WaitOne(0);