Пример #1
0
        /// <summary>
        /// Moves progress of AbortableBackgroundWorker to display.
        /// Progress is shown in Progressbar
        /// </summary>
        private void _WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.Invoke((Action) delegate
            {
                Progress.Value = Math.Min(100, e.ProgressPercentage);
                if (e.UserState != null && !string.IsNullOrEmpty(e.UserState.ToString()))
                {
                    ShowMessage(e.UserState.ToString());
                }

                if (!TimeOperation.IsRunning)
                {
                    TimeOperation.Start();
                }
                else
                {
                    TimeOperation.Stop();
                    TimeOpSmooth.Add(TimeOperation.ElapsedMilliseconds);
                    double t = TimeOpSmooth.Median;
                    if (_FileCounter > 0)
                    {
                        double timeLeftMs = t * (_FilesToGo - _FileCounter);
                        TimeLeft.Text     = $"Time left: {Toolbox.MillisecondsToString(timeLeftMs)}";
                    }
                    TimeOperation.Restart();
                }
            });
        }