Problem updating prog bar

I have a simple windows app that launches one thread. The thread processes files. After getting file count I set the progbar.maximum = filecount. progbar.minimum = 0

As each file is processed I call the Increment function  (all of this is done properly using delegates).

Everything seems to work ok except that the progress bar does not fill up all the way to the end. It will get about 3/4 full and the thread ends because it has finished.

I have stopped the program at the point the thread finishes and verified the filecount is correct and that the progbar.value = filecount.

Any clues as to why the progbar doesn't show the max amount?

Below is my update function being called from the thread.

Public Sub UpdateProgressBar()
        If statStrip.InvokeRequired Then
            Dim c As New HandleProgBarUpdate(AddressOf UpdateProgressBar)
        End If
    End Sub
Who is Participating?
CodeCruiserConnect With a Mentor Commented:
Try adding a doevents in UpdateProgressBar as well.
rutledgjAuthor Commented:
It is already there:

Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
I've gotten similar results in some of my own applications and never found a satisfactory explanation other than somehow .Net and/or the operating system is buffering the information being read and the last 1/4 goes by really fast because of this.

You try something like this to see what happens:

    Debug.Print(DateTime.Now & " : " & pg1.Value)
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

rutledgjAuthor Commented:
Does it matter that this is the progress bar that is part of the statusstrip?
Could you try something.. add a messagebox on click of the form which tells you the progress bar value. So when the files are processed, click on the form to ensure the value is really to maximum.

I've a similar progress bar in a status strip which works fine. Well, seems like because I never really checked carefully. This bar shows the progress of each email download, so it never lasts long. I'll look at it to see.
rutledgjAuthor Commented:
I tried this again this morning and now it works properly. I haven't changed anything so I'm not sure why it is now working.

I'm just going to share the points here to everyone.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.