Progressbar for generating hash
Hi,
I wish to create a progress bar for my program to compute hashes like SHA1.
Currently if I were to generate the hash from a large file, the application will look as if it is hang particularly when user click inside the form.
I am not sure whether progressbar is a good solution that can help to solve this issue, or at least let user know know the current progress so that they will wait for the computation to complete.
I came across a few methods for coding progress bar which mostly is based on manual coding/calculation. I wonder is there an automatic way which will generate the progress bar based on the class/function that I use e.g. SHA1CryptoServiceProvider
Please advise.
Thanks
Re: Progressbar for generating hash
Quote:
Originally Posted by
abcat
Hi,
I wish to create a progress bar for my program to compute hashes like SHA1.
Currently if I were to generate the hash from a large file, the application will look as if it is hang particularly when user click inside the form.
I am not sure whether progressbar is a good solution that can help to solve this issue, or at least let user know know the current progress so that they will wait for the computation to complete.
I came across a few methods for coding progress bar which mostly is based on manual coding/calculation. I wonder is there an automatic way which will generate the progress bar based on the class/function that I use e.g. SHA1CryptoServiceProvider
Please advise.
Thanks
A Progress bar would be your 2nd step, first look into using a Background Worker so your UI thread is free.
What is happening right now is your generating your Hash on the same thread as what your UI uses, so when the hash is being generated your UI is not able to work and redraw/function. So even if you put a progress bar it would not work.
Also instead of a progress bad showing total progress you could show the progress bar repeatedly going from 0 to 100 like some programs do
I am not well versed with background workers but perhaps someone else can chime in.
Re: Progressbar for generating hash
instead of a progress bar, something real simple that could let the user know it's working is change the cursor to the wait Me.Cursor = Cursors.WaitCursor then change it back to .default after it's complete.
Pat
Re: Progressbar for generating hash
I'd jsut use the progressbar in marquee mode... otherwise you have to figure out what the progression is... and unless the hash process reports how far along it is (unlikely) a traditional progbar that fills up isn't going to be accurate or easy to manage.
-tg
Re: Progressbar for generating hash
Based on all the responses, it is recommended for me to use a Background Worker so that my UI will not be 'hang' while computing. For the progress bar, I can use either a WaitCursor or ProgressBar (Marquee) to show just a loading indicator without any actual cacluation.
I guess this would be best and recommended way instead of going into the complex calculation.
Nevertheless, thanks for all the help :)
Re: Progressbar for generating hash
yyyyyup, that's it in a nutshell.
-tg