Mark Mintoff My superpower is common sense


C# Console Progress Bar

At work, I sometimes find myself needing to make Console applications which take some time. For example, I have a few console applications which parse dump files into objects and then insert the data into a database. Usually, I represent the progress of these applications with a simple incremental percentage display, however I thought I'd create a generic method which would display an ASCII progress bar.

The code itself is pretty self explanatory and probably more verbose than it really needs to be, but it gets the job done and looks good. It is a nice throwback to Pascal and QBasic for me.

EDIT: Amended code to append characters to a string before writing on screen. This fixes the flickering problem.

VN:F [1.9.22_1171]
Rating: 5.0/5 (13 votes cast)