Пример #1
0
        void DisplayProgress(object s, ElapsedEventArgs e)
        {
            int    files, dirs;
            long   bytesThisInterval;
            long   elapsedMs;
            long   msInterval;
            string fileName;

            lock (_lockStats)
            {
                files = numFilesCompleted;

                // Currently not using dirs completed, but keep them in case we want them later
                dirs = numDirectoriesCompleted;

                // Currently not using interval times or interval bytes, but keep them in case we want them later
                bytesThisInterval  = totalBytesCompleted - lastBytesCompleted;
                lastBytesCompleted = totalBytesCompleted;

                elapsedMs = progressStopwatch.ElapsedMilliseconds;
                fileName  = lastFileCompleted;
            }

            // Currently not using interval times or interval bytes, but keep them in case we want them later
            msInterval    = elapsedMs - lastElapsedMs;
            lastElapsedMs = elapsedMs;

            double readSpeedBytesPerMin = ((double)lastBytesCompleted) / (elapsedMs / (MillisecondsPerSecond * SecondsPerMinute));

            lock (ConsoleUtil._lockGlobalConsole)
            {
                ConsoleUtil.White();
                Console.Write(ProgressFormat, backspaces, spaces, files, FileUtil.FormatByteSize(lastBytesCompleted), TimerUtil.FormatMilliseconds(lastElapsedMs), FileUtil.FormatByteSize((long)readSpeedBytesPerMin),
                              FileUtil.TrimFileName(fileName, ConsoleMaxFileNameLength));
                ConsoleUtil.RestoreColors();
            }
        }