예제 #1
0
        /// <summary>
        ///     Increments the progressbar value by 1 taking into consideration
        ///     multithreading.
        /// </summary>
        /// <param name="control">The current progressbar.</param>
        public static void Increment(this ProgressBar control, System.Windows.Controls.Label label = null)
        {
            if (!control.Dispatcher.CheckAccess())
            {
                control.Dispatcher.Invoke(() =>
                {
                    control.Increment(label);
                });
                return;
            }

            if (control.Value >= control.Maximum)
            {
                return;
            }

            control.Value++;

            if (label == null)
            {
                return;
            }

            var progress = (control.Value / control.Maximum) * 100;

            label.Content = Math.Round(progress, 1) + "%";
        }