Problem updating prog bar

Posted on 2011-10-28
Last Modified: 2012-05-12
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
Question by:rutledgj
    LVL 83

    Accepted Solution

    Try adding a doevents in UpdateProgressBar as well.

    Author Comment

    It is already there:

    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    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)

    Author Comment

    Does it matter that this is the progress bar that is part of the statusstrip?
    LVL 9

    Expert Comment

    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.

    Author Comment

    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.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now