C# Class PowerArgs.Cli.CliProgressBar

A utility that lets you display a progress bar on the console
Show file Open project: adamabdelhamed/PowerArgs

Public Methods

Method Description
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

Private Methods

Method Description
DrawBorder ( ) : void
DrawHorizontalLine ( ) : void

Method Details

CliProgressBar() public method

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
return System

CliProgressBar() public method

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
return System

Render() public method

Renders the entire progress bar
public Render ( ) : void
return void

RenderAndPollDeterminate() public method

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
return void

RenderAndPollIndeterminate() public method

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
return void

RenderUntilIndeterminate() public method

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
return void

RenderUntilIndeterminate() public method

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.
return void

Update() public method

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
return void

Wipe() public method

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
return void