Update a progressbar when steps are arbitrary
I am writing a C# application where I process lines in a file. The file
may have 2 lines, 30, 80, maybe over a hundred lines.
The lines are stored in a list, so I can get the line count from
myFileList.Count. The progressbar only takes int as arguments to the
value, so if I have line number of say 50, I could easily do
int steps = 100/myFileList.Count
progress += steps;
updateProgressBar ( progress );
But what if my file has say 61 lines: 100/61 = 1,64, hence int steps will
be equal to 1 and my progress bar will stop at 61 percent. How can I do
this correctly?
No comments:
Post a Comment