예제 #1
0
        static int Main(string[] args)
        {
            var client   = NitroClient.FromJson();
            var progress = new ConsoleProgress();

            var key = client.GetKeyInfo();

            if (key is null)
            {
                Console.Error.WriteLine("Can't get key");
                return(1);
            }

            if (!key.IsActive())
            {
                Console.Error.WriteLine("Key is not active");
                return(1);
            }

            Console.WriteLine($"Today traffic left: {(key.TrafficLeft / 1024 / 1024):N0} Mb");

            if (args.Length != 0)
            {
                foreach (var url in args)
                {
                    client.DownloadFile(url, progress);
                }

                Console.WriteLine();
                Console.WriteLine("ALL DONE");
                Console.WriteLine();
            }

            return(0);
        }
        public void ConsoleProgressExample()
        {
            var firstProgress  = new ConsoleProgress(title: "ConsoleProgress", length: 50);
            var secondProgress = new SimpleProgress(title: "SimpleProgress", length: 50);

            var flow = new ConsoleFlow
                       (
                firstProgress,
                secondProgress
                       );

            flow.Display();

            while (true)
            {
                var key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (key == ConsoleKey.UpArrow)
                {
                    firstProgress.Value = Math.Clamp(firstProgress.Value + 0.1f, 0f, 1f);
                }
                else if (key == ConsoleKey.DownArrow)
                {
                    secondProgress.Value = Math.Clamp(secondProgress.Value + 0.1f, 0f, 1f);
                }
            }
        }
예제 #3
0
파일: Demo.cs 프로젝트: HTD/Woof.Console
    static void Main()
    {
        Console.SetOut(new HexColor());
        ConsoleEx.AssemblyHeader(useColor: true);
        Console.WriteLine("Testing `066`Woof.Console`:");
        Console.WriteLine();
        var tasksCount = TasksLeft = 8;

        for (int i = 0; i < tasksCount; i++)
        {
            lock (L1) {
                Console.Write($"Starting test task #{i + 1}...");
                var progress = new ConsoleProgress();
                Task.Run(async() => await TestTask(progress));
                Task.Delay(1).Wait();
            }
        }
        Semaphore.Wait();
        Console.WriteLine();
        using var hexDump = new HexDump { Format = HexDump.Formats.HexColor };
        var testData = new byte[48];

        PRNG.NextBytes(testData);
        hexDump.Write(testData);
        Console.WriteLine();
        var delayFilter = new Delay();

        Console.SetOut(delayFilter);
        Console.WriteLine("Testing `0ff`Delay` filter..............`070`OK!`");
        Console.SetOut(delayFilter.Out); // remove the delay filter.
        Console.WriteLine();
        ConsoleEx.WaitForCtrlC("All test completed successfully, press Ctrl+C to exit...");
    }
예제 #4
0
        private void ReadTables(CremaDataSet dataSet, IDataBase dataBase, string tableNames)
        {
            var authentication = this.CommandContext.GetAuthentication(this);
            var tables         = dataBase.Dispatcher.Invoke(() => this.GetFilterTables(dataBase.TableContext.Tables, tableNames));

            if (tables.Any() == false)
            {
                throw new CremaException("조건에 맞는 테이블이 존재하지 않습니다.");
            }
            var step = new StepProgress(new ConsoleProgress(this.Out)
            {
                Style = ConsoleProgressStyle.None
            });

            step.Begin(tables.Length);
            foreach (var item in tables)
            {
                dataBase.Dispatcher.Invoke(() =>
                {
                    var previewSet   = item.GetDataSet(authentication, -1);
                    var previewTable = previewSet.Tables[item.Name];
                    previewTable.CopyTo(dataSet);
                    var name = item.Name;
                    step.Next("read {0} : {1}", ConsoleProgress.GetProgressString(step.Step + 1, tables.Length), item.Name);
                });
            }
            step.Complete();
        }
예제 #5
0
        public static void ApplyFix()
        {
            if (!ActiveFix)
            {
                return;
            }

            var patchPath = Path.Combine(Path.GetDirectoryName(Plugin.CurrentPlugin.Context.AssemblyPath), "./maps_bindings_fix.sql");

            logger.Debug("Apply maps bindings fix");

            if (File.Exists(patchPath))
            {
                File.Delete(patchPath);
            }
            var console = new ConsoleProgress();
            var maps    = World.Instance.GetMaps().ToArray();
            var counter = 0;
            var patches = 0;

            foreach (var request in maps.Select(FixMap))
            {
                if (request != string.Empty)
                {
                    File.AppendAllText(patchPath, request + "\r\n");
                    patches++;
                }

                counter++;

                console.Update(string.Format("{0:0.0}% " + "({1} patches)", (counter / (double)maps.Length) * 100, patches));
            }
        }
예제 #6
0
        private static void OnChunkDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            ChildProgressBar progress = ChildConsoleProgresses.GetOrAdd(e.ProgressId, id =>
                                                                        ConsoleProgress?.Spawn(10000, $"chunk {id}", ChildOption));

            progress.Tick((int)(e.ProgressPercentage * 100));
        }
예제 #7
0
        public static void ApplyFix()
        {
            var worldDb = Program.ConnectToWorld();

            Console.WriteLine("Load maps ...");
            World.Instance.ChangeDataSource(worldDb.Database);
            World.Instance.LoadSpaces();
            var console = new ConsoleProgress();

            Console.WriteLine("Apply fix ...");
            var maps    = World.Instance.GetMaps().ToArray();
            var counter = 0;
            var patches = 0;

            foreach (var map in maps)
            {
                FixMap(map);
                worldDb.Database.Update(map.Record);

                counter++;

                console.Update(string.Format("{0:0.0}% " + "({1} patches)", (counter / (double)maps.Length) * 100, patches));
            }
            console.End();
            Console.WriteLine("Maps transitions fix applied");
        }
예제 #8
0
        public void CanGetNewFileFromAnotherRep()
        {
            ConsoleProgress progress = new ConsoleProgress();
            BobSetup        bobSetup = new BobSetup(progress, _pathToTestRoot);

            bobSetup.ChangeTextFile();
            string usbPath = Path.Combine(_pathToTestRoot, "USB-A");

            Directory.CreateDirectory(usbPath);
            bobSetup.SetupClone(usbPath);

            RepositoryAddress otherDirPath = RepositoryAddress.Create("USBA", Path.Combine(usbPath, RepositoryAddress.ProjectNameVariable), false);
            Synchronizer      bob          = bobSetup.GetSynchronizer();

            bob.ExtraRepositorySources.Add(otherDirPath);

            //now stick a new file over in the "usb", so we can see if it comes back to us
            File.WriteAllText(Path.Combine(otherDirPath.GetPotentialRepoUri(bob.Repository.Identifier, BobSetup.ProjectFolderName, progress), "incoming.abc"), "this would be a file coming in");
            var options = GetFullSyncOptions("adding a file to the usb for some reason");
            ProjectFolderConfiguration usbProject = BobSetup.CreateFolderConfig(Path.Combine(usbPath, BobSetup.ProjectFolderName));
            var synchronizer = Synchronizer.FromProjectConfiguration(usbProject, progress);

            synchronizer.Repository.SetUserNameInIni("usba", progress);
            synchronizer.SyncNow(options);

            //now we should get that file
            options = GetFullSyncOptions("test getting new file from usb");
            options.DoMergeWithOthers = false;
            options.DoSendToOthers    = false;
            options.RepositorySourcesToTry.Add(otherDirPath);
            bob.SyncNow(options);
            Assert.That(Path.Combine(bobSetup._languageProjectPath, "incoming.abc"), Does.Exist);
        }
예제 #9
0
 public HgTestSetup()
 {
     _progress = new ConsoleProgress();
     Root      = new TemporaryFolder("ChorusHgWrappingTest");
     HgRepository.CreateRepositoryInExistingDir(Root.Path, _progress);
     Repository = new HgRepository(Root.Path, new NullProgress());
 }
예제 #10
0
        private void Read()
        {
            try
            {
                using (FileStream _compressedFile = new FileStream(SourceFile, FileMode.Open))
                {
                    while (_compressedFile.Position < _compressedFile.Length)
                    {
                        byte[] lengthBuffer = new byte[8];                             //8
                        _compressedFile.Read(lengthBuffer, 0, lengthBuffer.Length);
                        int    blockLength    = BitConverter.ToInt32(lengthBuffer, 4); //4
                        byte[] compressedData = new byte[blockLength];
                        lengthBuffer.CopyTo(compressedData, 0);
                        _compressedFile.Read(compressedData, 8, blockLength - 8);
                        int    _dataSize  = BitConverter.ToInt32(compressedData, blockLength - 4);//-4
                        byte[] lastBuffer = new byte[_dataSize];

                        ByteBlock _block = new ByteBlock(_counter, lastBuffer, compressedData);
                        QueueReader.EnqueueForWriting(_block);
                        _counter++;

                        ConsoleProgress.ProgressBar(_compressedFile.Position, _compressedFile.Length);
                    }
                    QueueReader.Stop();
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Cancelled = true;
            }
        }
예제 #11
0
        public void Sync_NonExistantLangDepotProject_ExitsGracefullyWithCorrectErrorResult()
        {
            _model = new SyncControlModel(_project, SyncUIFeatures.Minimal, null);
            _model.SyncOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("languageforge", "http://hg-public.languagedepot.org/dummy"));
            var progress = new ConsoleProgress()
            {
                ShowVerbose = true
            };

            _model.AddMessagesDisplay(progress);
            SyncResults results = null;

            _model.SynchronizeOver += new EventHandler((sender, e) => results = (sender as SyncResults));
            _model.Sync(true);
            var start = DateTime.Now;

            while (results == null)
            {
                Thread.Sleep(100);
                Application.DoEvents();            //else the background worker may starve
                if ((DateTime.Now.Subtract(start).Minutes > 1))
                {
                    Assert.Fail("Gave up waiting.");
                }
            }
            Assert.IsFalse(results.Succeeded);
            Assert.IsNotNull(results.ErrorEncountered);
        }
예제 #12
0
        public void Run_PathHasDangerousCharacters_DoesCopy()
        {
            //couldn't make it break on what came to me over email: var problemPart = "07Support&F 7f3";
            var problemPart = "{9}";

            using (var from = new TemporaryFolder("synctest_source"))
                using (var to = new TemporaryFolder("synctest_dest"))
                {
                    using (var sub = new TemporaryFolder(from, problemPart))
                    {
                        var fileName = "1.txt";
                        System.IO.File.WriteAllText(sub.Combine(fileName), "Blah blah");
                        var source   = new RawDirectoryGroup("1", from.Path, null, null);
                        var groups   = new List <FileGroup>(new[] { source });
                        var progress = new ConsoleProgress()
                        {
                            ShowVerbose = true
                        };

                        var sync = new MirrorController(to.Path, groups, 100, progress);

                        sync.Run();
                        string path = to.Combine("1", problemPart, fileName);
                        Assert.That(File.Exists(path), path);
                    }
                }
        }
예제 #13
0
        private static void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            double nonZeroSpeed = e.BytesPerSecondSpeed + 0.0001;
            int    estimateTime = (int)((e.TotalBytesToReceive - e.BytesReceived) / nonZeroSpeed);
            bool   isMinutes    = estimateTime >= 60;
            string timeLeftUnit = "seconds";
            bool   isElapsedTimeMoreThanOneSecond = Environment.TickCount64 - LastTick >= 1000;

            ConsoleProgress.Tick((int)(e.ProgressPercentage * 100));

            if (isMinutes)
            {
                timeLeftUnit  = "minutes";
                estimateTime /= 60;
            }

            if (isElapsedTimeMoreThanOneSecond)
            {
                AverageSpeed.Add(e.BytesPerSecondSpeed);
                LastTick = Environment.TickCount64;
            }

            string avgSpeed            = CalcMemoryMensurableUnit((long)AverageSpeed.Average());
            string speed               = CalcMemoryMensurableUnit(e.BytesPerSecondSpeed);
            string bytesReceived       = CalcMemoryMensurableUnit(e.BytesReceived);
            string totalBytesToReceive = CalcMemoryMensurableUnit(e.TotalBytesToReceive);
            string progressPercentage  = $"{e.ProgressPercentage:F3}".Replace("/", ".");

            Console.Title = $"{progressPercentage}%  -  " +
                            $"{speed}/s (avg: {avgSpeed}/s)  -  " +
                            $"[{bytesReceived} of {totalBytesToReceive}], " +
                            $"{estimateTime} {timeLeftUnit} left";
        }
예제 #14
0
        public void CanCollaborateOnLift()
        {
            ConsoleProgress progress = new ConsoleProgress();
            BobSetup        bobSetup = new BobSetup(progress, _pathToTestRoot);

            bobSetup.ChangeTextFile();

            //Ok, this is unrealistic, but we just clone Bob onto Sally
            string sallyMachineRoot = Path.Combine(_pathToTestRoot, "sally");

            Directory.CreateDirectory(sallyMachineRoot);
            string sallyProjectRoot = bobSetup.SetupClone(sallyMachineRoot);
            ProjectFolderConfiguration sallyProject = BobSetup.CreateFolderConfig(sallyProjectRoot);

            var repository = HgRepository.CreateOrUseExisting(sallyProject.FolderPath, progress);

            repository.SetUserNameInIni("sally", progress);

            // bob makes a change and syncs
            File.WriteAllText(bobSetup._pathToLift, LiftFileStrings.lift12Dog);
            var bobOptions = new SyncOptions
            {
                CheckinDescription = "added 'dog'",
                DoMergeWithOthers  = false,                                                                     // just want a fast checkin
                DoSendToOthers     = false,                                                                     // just want a fast checkin
                DoPullFromOthers   = false                                                                      // just want a fast checkin
            };

            bobSetup.GetSynchronizer().SyncNow(bobOptions);

            //now Sally modifies the original file, not having seen Bob's changes yet
            var sallyPathToLift = Path.Combine(sallyProject.FolderPath, Path.Combine("lexicon", "foo.lift"));

            File.WriteAllText(sallyPathToLift, LiftFileStrings.lift12Cat);

            //Sally syncs, pulling in Bob's change, and encountering a need to merge (no conflicts)
            var sallyOptions = new SyncOptions
            {
                CheckinDescription = "adding cat",
                DoPullFromOthers   = true,
                DoSendToOthers     = true,
                DoMergeWithOthers  = true
            };

            sallyOptions.RepositorySourcesToTry.Add(RepositoryAddress.Create("bob's machine", bobSetup.BobProjectPath, false));

            var synchronizer = Synchronizer.FromProjectConfiguration(sallyProject, progress);

            synchronizer.SyncNow(sallyOptions);

            //Debug.WriteLine("bob's: " + File.ReadAllText(bobSetup._pathToLift));
            var contents = File.ReadAllText(sallyPathToLift);

            //Debug.WriteLine("sally's: " + contents);
            Assert.That(contents, Does.Contain("cat"));
            Assert.That(contents, Does.Contain("dog"));
        }
예제 #15
0
        public void BasicTest()
        {
            var labels   = array("alpha", "bravo", "charlie", "delta", "echo", "foxtrot");
            var progress = new ConsoleProgress(10, 30);

            foreach (var label in labels)
            {
                progress.Progress(label, true);
            }
        }
예제 #16
0
        public override void OnExit(MethodExecutionArgs args)
        {
            ConsoleProgress progress = new ConsoleProgress();

            progress.ProgressBar(60);
            for (int i = 0; i < 101; i++)
            {
                progress.Update(i);
                System.Threading.Thread.Sleep(25);
            }
        }
예제 #17
0
 public void MakeClone_NoProblems_MakesClone()
 {
     using (var repo = new RepositorySetup("source"))
         using (var f = new TemporaryFolder("clonetest"))
         {
             var model    = new CloneFromUsb();
             var progress = new ConsoleProgress();
             progress.ShowVerbose = true;
             model.MakeClone(repo.ProjectFolder.Path, f.Path, progress);
             Assert.IsTrue(Directory.Exists(f.Combine(RepositorySetup.ProjectName, ".hg")));
         }
 }
예제 #18
0
        public void ErrorsEncountered_ErrorOriginatesWithOneHandler_MultiProgressHasErrorsEncountered()
        {
            var multiProgress  = new MultiProgress();
            var statusProgress = new StatusProgress();

            multiProgress.Add(statusProgress);
            var consoleProgress = new ConsoleProgress();

            multiProgress.AddMessageProgress(consoleProgress);
            statusProgress.WriteError("some error happened!");
            Assert.That(multiProgress.ErrorEncountered, Is.True);
        }
예제 #19
0
        public void ErrorsEncountered_ErrorOriginatesWithMultiProgress_BothHandlersHaveErrorsEncountered()
        {
            var multiProgress  = new MultiProgress();
            var statusProgress = new StatusProgress();

            multiProgress.Add(statusProgress);
            var consoleProgress = new ConsoleProgress();

            multiProgress.AddMessageProgress(consoleProgress);
            multiProgress.WriteError("error!");
            Assert.That(consoleProgress.ErrorEncountered, Is.True);
            Assert.That(statusProgress.ErrorEncountered, Is.True);
        }
예제 #20
0
        /// <summary>
        /// Train on a set of patterns a specified number of iterations.
        /// </summary>
        /// <param name="folder">The folder which contains the images to train on. Each image MUST be named with the solution to the CAPTCHA.</param>
        /// <param name="iterations">The number of iterations to train.</param>
        /// <returns></returns>
        public PatternResult TrainOnSet(string folder, int iterations)
        {
            SolutionSet set = LoadSolutionSet(folder);

            if (set.Patterns.Count == 0)
            {
                set = CreateSolutionSet(folder);
            }

            using (trainingProgress = new ConsoleProgress("Training "))
            {
                return(Train(set, iterations));
            }
        }
예제 #21
0
        public override void OnExit(MethodExecutionArgs args)
        {
            ConsoleProgress progress = new ConsoleProgress();

            progress.ProgressBar(60);
            for (int i = 0; i < 101; i++)
            {
                progress.Update(i);
                System.Threading.Thread.Sleep(50);
            }
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nPizza hazır. Afiyet olsun.");
        }
예제 #22
0
 public static ConsoleProgress <DataTransferProgress> CreateTransferConsoleProgress(string name)
 {
     return(ConsoleProgress.Create <DataTransferProgress>(name, (p, c) =>
     {
         if (p.Description != null)
         {
             c.Report(p.Description);
         }
         else if (p.Progress != null)
         {
             c.Report(p.Progress.Value);
         }
     }));
 }
예제 #23
0
파일: Demo.cs 프로젝트: HTD/Woof.Console
    public static async Task TestTask(ConsoleProgress p)
    {
        var randomDelayValue = PRNG.Next(50, 150);

        for (int i = 0; i < 10; i++)
        {
            await Task.Delay(randomDelayValue);

            p.Dot();
        }
        lock (L1) p.Done("`070`OK!`");
        if (--TasksLeft < 1)
        {
            Semaphore.Release();
        }
    }
예제 #24
0
        static void Main(string[] args)
        {
            var pathname = args[0];
            var prog     = new ConsoleProgress();
            var data     = new FwData(pathname, prog);

            data.FixErrorsAndSave();
            if (prog.DotsWritten)
            {
                Console.WriteLine();
            }
            foreach (var err in data.Errors)
            {
                Console.WriteLine(err);
            }
        }
예제 #25
0
        private static async Task Populate(params ISeriesParser[] parser)
        {
            var options = new ProgressBarOptions
            {
                ForegroundColor   = ConsoleColor.Yellow,
                BackgroundColor   = ConsoleColor.DarkYellow,
                ProgressCharacter = '─'
            };

            var memCache = new MemFile();

            var manager = new MangaDownloader(new FileSystem(), parser, Client2.GetDocumentAsync);
            var index   = new MangaIndex(manager, null, memCache);

            var             first = true;
            ConsoleProgress pb    = null;

            IProgress <double> GetProgress(string context)
            {
                pb?.Dispose();
                if (first)
                {
                    first = false;
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine();
                }

                return(pb = new ConsoleProgress(options, context));
            }

            try
            {
                await index.Update(GetProgress);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            //res = await Task.WhenAll(manager.Providers.Select(p => manager.ListInstances(p, pb).ContinueWith(t => (t.Result, provider: p))));


            //var res = await MyDictionary;
            //MyDictionary = new AsyncLazy<Dictionary<string, MangaInfo>>(CreateDictionary);
        }
예제 #26
0
        public void MakeClone_TargetExists_CreatesCloneInWhenTargetIsEmpty()
        {
            using (var repo = new RepositorySetup("source"))
                using (var f = new TemporaryFolder("clonetest"))
                {
                    var model    = new CloneFromUsb();
                    var progress = new ConsoleProgress();
                    progress.ShowVerbose = true;
                    var extantFolder = f.Combine(RepositorySetup.ProjectName);
                    Directory.CreateDirectory(extantFolder);

                    var cloneFolder = model.MakeClone(repo.ProjectFolder.Path, f.Path, progress);
                    Assert.AreEqual(extantFolder, cloneFolder);
                    Assert.IsTrue(Directory.Exists(extantFolder));
                    Assert.IsFalse(Directory.Exists(extantFolder + "1"));
                }
        }
예제 #27
0
        private static void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            var nonZeroSpeed = e.BytesPerSecondSpeed == 0 ? 0.0001 : e.BytesPerSecondSpeed;
            var estimateTime = (int)((e.TotalBytesToReceive - e.BytesReceived) / nonZeroSpeed);
            var isMins       = estimateTime >= 60;
            var timeLeftUnit = "seconds";

            if (isMins)
            {
                timeLeftUnit  = "mins";
                estimateTime /= 60;
            }

            Console.Title = $"{e.ProgressPercentage:N3}%  -  {CalcMemoryMensurableUnit(e.BytesPerSecondSpeed)}/s  -  " +
                            $"[{CalcMemoryMensurableUnit(e.BytesReceived)} of {CalcMemoryMensurableUnit(e.TotalBytesToReceive)}], {estimateTime} {timeLeftUnit} left";
            ConsoleProgress.Tick((int)(e.ProgressPercentage * 100));
        }
예제 #28
0
        static void Main(string[] args)
        {
            IProgress progress = null;

            if (args.Contains("--silent"))
            {
                progress = new SilentProgress();
            }
            else
            {
                progress = new ConsoleProgress();
            }

            string inputFolder = Directory.GetCurrentDirectory();
            int    i           = args.ToList().IndexOf("--folder");

            if (i >= 0 && i + 1 < args.Count())
            {
                inputFolder = args[i + 1];
            }

            string logfilepath = Path.Combine(inputFolder, "Log", "log-.txt");

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.File(logfilepath, rollingInterval: RollingInterval.Day)
                         .CreateLogger();

            Stopwatch sw = new Stopwatch();

            sw.Start();

            try
            {
                new TopStopWork(progress)
                .WithFolder(inputFolder)
                .ProcessFolder();
            }
            catch (Exception ex)
            {
                Log.Error($"Error processing folder {inputFolder}: {ex}");
            }

            sw.Stop();
            Log.Information($"Folder {inputFolder} took {HumanTime(sw)} (more precisely, {sw.ElapsedMilliseconds / 1000.0} sec) to process.");
        }
예제 #29
0
        void BetterLoading()
        {
            Console.WriteLine();
            Write("We will now simulate a more complex loading sample, please wait!");

            Console.CursorVisible   = false;
            Console.ForegroundColor = ConsoleColor.Green;

            for (var i = 0; i <= 100; i++)
            {
                Thread.Sleep(20);
                ConsoleProgress.SetProgress(i, Console.WindowWidth);
            }

            Console.CursorVisible   = true;
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine();
        }
예제 #30
0
        private void Read()
        {
            try
            {
                using (FileStream sourceFile = new FileStream(base.sourceFile, FileMode.Open))
                {
                    int    bytesRead;
                    byte[] lastBuffer;
                    long   fileLength = sourceFile.Length;

                    while (sourceFile.Position < fileLength && !cancelled)
                    {
                        if (queueReader.Count() > maxQueueSize || queueWriter.Count() > maxQueueSize)
                        {
                            continue;
                        }

                        if (fileLength - sourceFile.Position <= chunkSize)
                        {
                            bytesRead = (int)(fileLength - sourceFile.Position);
                        }
                        else
                        {
                            bytesRead = chunkSize;
                        }

                        lastBuffer = new byte[bytesRead];
                        sourceFile.Read(lastBuffer, 0, bytesRead);
                        queueReader.EnqueueForCompress(lastBuffer);

                        ConsoleProgress.ProgressBar(sourceFile.Position, sourceFile.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                cancelled = true;
            }
            finally
            {
                queueReader.Stop();
            }
        }