logo
VitNX3 Documentation

# ProgressBar.Update (Double) Method

Namespace: VitNX3.UI.Console.ProgressBar
Assembly: VitNX3 (in VitNX3.dll)
Update the progress by percent.
VB
C#
F#
C++
JScript
Copy

    public void Update(
       double percent
    )

    This language is not supported or no code example is available.

#### Parameters

percent
  double

The processed percentage.

Source code
VB
C#
F#
C++
JScript
Copy

    public void Update(double percent)
     {
         if (enabled == false)
             return;
         if (Math.Round(percent * 100) <= this.percentage)
             return;
         int originCursorTop = System.Console.CursorTop;
         int originCursorLeft = System.Console.CursorLeft;
         ConsoleColor originBackgroundColor = System.Console.BackgroundColor;
         ConsoleColor originForegroundColor = System.Console.ForegroundColor;
         int width = System.Console.WindowWidth - textWidth;
         percentage = (int)Math.Round(percent * 100);
         System.Console.SetCursorPosition(0, cursorTop);
         System.Console.Write(new string(' ', textWidth));
         System.Console.SetCursorPosition(0, cursorTop);
         System.Console.Write($"{percentage}%");
         System.Console.BackgroundColor = originForegroundColor;
         int newCursorLeft = (int)Math.Round(percent * width);
         for (int cursor = cursorLeft; cursor < newCursorLeft; cursor++)
         {
             System.Console.SetCursorPosition(textWidth + cursor, cursorTop);
             System.Console.Write(' ');
         }
         System.Console.BackgroundColor = originBackgroundColor;
         System.Console.ForegroundColor = originForegroundColor;
         System.Console.CursorTop = originCursorTop;
         System.Console.CursorLeft = originCursorLeft;
         cursorLeft = newCursorLeft;
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
ProgressBar Class
VitNX3.UI.Console.ProgressBar Namespace