Indicating progress in console windows
Published January 5th, 2010 in ProgrammingCommand-line interface tools. We usually prefer to write these when we need a lightweight application to get work done.
Some operations can be lengthy, or we simply want to present the a visual indicator of progress to the user. For this purpose I usually update Console.Title for simplicity’s sake.
However, if the tool is intended for a more wide audience (IT professionals or advanced users) you would want a CLI progress bar.
ConsoleProgress is a static class. Usage is pretty much straight-forward:
- Call Reset to reset the progress bar’s state. This is optional if you wish to use the progress bar only once in your program.
- Call Update. You can pass a float to indicate progress using a fraction (0.25 = 25%), or the current and maximum values (e.g. 17 of 100 items processed).
- If the operation can be canceled, either because of an internal exception or by the user, you can set the Canceled property to true to update the console output.
The sample code also contains several test cases, which demonstrate successful and canceled operations. I have also used relevant colors depending on each result.
Search
About |
Currently, he is administering AeroXperience and coding using Visual Studio 2008 on Windows 7.
Latest
- Decoding FLAC audio files in C#
- Inline Tweet Translator
- Resizing forms while keeping aspect ratio
- Encoding uncompressed audio with FLAC in C#
- Indicating progress in console windows
- 2010
- Windows 7 – Какво ново?
- Most Valuable Professional and what’s to come
- Tweak DWM from your programs, Part 3
- Tweak DWM from your programs, Part 2

No Responses to “Indicating progress in console windows”
Please Wait
Leave a Reply