Problem updating prog bar

Posted on 2011-10-28
Medium Priority
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

CodeCruiser earned 252 total points
ID: 37046086
Try adding a doevents in UpdateProgressBar as well.

Author Comment

ID: 37046224
It is already there:

LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 248 total points
ID: 37046290
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)
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 37046431
Does it matter that this is the progress bar that is part of the statusstrip?

Expert Comment

ID: 37048553
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

ID: 37056750
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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