C# Класс PowerArgs.Cli.CliProgressBar

A utility that lets you display a progress bar on the console
Показать файл Открыть проект

Открытые методы

Метод Описание
CliProgressBar ( ConsoleString initialMessage = null, int width = null ) : System

Creates a new progress bar given a width

CliProgressBar ( string initialMessage, int width = null ) : System

Creates a new progress bar given a width

Render ( ) : void

Renders the entire progress bar

RenderAndPollDeterminate ( System.Action pollAction, System.TimeSpan pollingInterval ) : void

Renders the progress bar and automatically updates it on a polling interval. The method blocks until the progress reaches 1 or your poll action throws an OperationCancelledException, whichever comes first. It is expected that you will update the progress via the poll action. You can also update the message during the poll action.

RenderAndPollIndeterminate ( Func heartbeat, System.TimeSpan pollingInterval ) : void

Renders the progress bar and shows an indeterminate progress animation until the operation completes

RenderUntilIndeterminate ( System.Action workAction ) : void

Renders the progress bar and shows an indeterminate progress animation. Simultaneously, the work action is started. The bar will animate as long as the work action is running.

RenderUntilIndeterminate ( Task workTask ) : void

Renders the progress bar and shows an indeterminate progress animation until the Task completes. This method will not start the task so it must be started somewhere else.

Update ( ) : void

Renders the middle portion of the progress bar that contains the message and progress fill. You must have called Render() ahead of time for this to make sense.

Wipe ( ) : void

Clears the progress bar from the console and restores the console to the position it was in before drawing the progress bar

Приватные методы

Метод Описание
DrawBorder ( ) : void
DrawHorizontalLine ( ) : void

Описание методов

CliProgressBar() публичный Метод

Creates a new progress bar given a width
public CliProgressBar ( ConsoleString initialMessage = null, int width = null ) : System
initialMessage ConsoleString an initial message to display in the progress bar
width int the width to use or null to use the default width which is one third of the console buffer width
Результат System

CliProgressBar() публичный Метод

Creates a new progress bar given a width
public CliProgressBar ( string initialMessage, int width = null ) : System
initialMessage string an initial message to display in the progress bar
width int the width to use or null to use the default width which is one third of the console buffer width
Результат System

Render() публичный Метод

Renders the entire progress bar
public Render ( ) : void
Результат void

RenderAndPollDeterminate() публичный Метод

Renders the progress bar and automatically updates it on a polling interval. The method blocks until the progress reaches 1 or your poll action throws an OperationCancelledException, whichever comes first. It is expected that you will update the progress via the poll action. You can also update the message during the poll action.
public RenderAndPollDeterminate ( System.Action pollAction, System.TimeSpan pollingInterval ) : void
pollAction System.Action An action to run on each polling interval
pollingInterval System.TimeSpan The polling interval
Результат void

RenderAndPollIndeterminate() публичный Метод

Renders the progress bar and shows an indeterminate progress animation until the operation completes
public RenderAndPollIndeterminate ( Func heartbeat, System.TimeSpan pollingInterval ) : void
heartbeat Func a function that should return true as long as you want to continue to block. If you return false then this method will return.
pollingInterval System.TimeSpan How fast you want the progress bar to call your heartbeat function
Результат void

RenderUntilIndeterminate() публичный Метод

Renders the progress bar and shows an indeterminate progress animation. Simultaneously, the work action is started. The bar will animate as long as the work action is running.
public RenderUntilIndeterminate ( System.Action workAction ) : void
workAction System.Action
Результат void

RenderUntilIndeterminate() публичный Метод

Renders the progress bar and shows an indeterminate progress animation until the Task completes. This method will not start the task so it must be started somewhere else.
public RenderUntilIndeterminate ( Task workTask ) : void
workTask Task the task to wait for. This method will not start the task so it must be started somewhere else.
Результат void

Update() публичный Метод

Renders the middle portion of the progress bar that contains the message and progress fill. You must have called Render() ahead of time for this to make sense.
public Update ( ) : void
Результат void

Wipe() публичный Метод

Clears the progress bar from the console and restores the console to the position it was in before drawing the progress bar
public Wipe ( ) : void
Результат void