Progressbar not hitting 100% when expected

blawford

I am using a background thread to run a stopwatch which I am using on a label and to increment a progressbar. The timer seems to be keeping time accurately but the progress bar isn't hitting 100% when I expect it to.

I am trying to use both to time 35 seconds and it hits 100% at nearly 36s, can anyone tell me why?

The Maximum value of the progress bar is set to 350, value is set to 0.

private int currentScore = 0;

Stopwatch swTimer = new Stopwatch();

private void backgroundWorkerTimer_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    TimeSpan elapsedTime = swTimer.Elapsed;
    labelTime.Text = String.Format("{0}.{1:%f}", elapsedTime.Seconds, elapsedTime);
    progressBarTimer.Increment(1);
}

private void backgroundWorkerTimer_DoWork(object sender, DoWorkEventArgs e)
{
    while (true)
    {
        backgroundWorkerTimer.ReportProgress(0);
        System.Threading.Thread.Sleep(100);
    }            
}
blawford

This seems to have dried up so I will close it. I ended up making the progressBar max 345 and it seems to hit the end at about 35s, I am only using it for a visual representation of time left anyway.

Would be interested to know why 350 as a maximum isn't accurate though when labelTime is keeping up.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Zlib::BufError when using progressbar/ruby-progressbar gem

From Dev

Prevent Error Message from Appearing When Hitting Cancel of Opening a File

From Dev

moving a circle backward when hitting the canvas x border

From Dev

jQuery: add line break at cursor position when hitting Enter

From Dev

How to define a nested route to render when hitting the parent in Ember

From Dev

Body lost a velocity component when hitting a wall

From Dev

curl vs python "requests" when hitting APIs

From Dev

What to do when hitting the queue size of slick?

From Dev

Stop default Autocomplete behavior when hitting spacebar in Visual Studio 2015

From Dev

Scanner loop doesn't cycle when hitting enter twice

From Dev

How to kill Android app 100% when hitting Back

From Dev

Show response everytime when hitting the api in volley

From Dev

gvim produces error when hitting the close window

From Dev

How to shutdown the computer when hitting the Power button?

From Dev

What does WorkManager do with jobs after hitting JobScheduler limit of 100?

From Dev

How to shutdown the computer when hitting the Power button?

From Dev

Vim tab size when hitting <Tab> and when autoindent applies

From Dev

VMWare Workstation CPU Usage hitting 100%

From Dev

SpriteKit Jumping when hitting Ground

From Dev

Android ProgressBar not updating as expected?

From Dev

Zlib::BufError when using progressbar/ruby-progressbar gem

From Dev

Firefox - width: 100% not working as expected

From Dev

AVAudioPlayer not resuming when hitting stop button

From Dev

What to do when hitting the queue size of slick?

From Dev

ProgressBar in AsyncTask is showing values more 100

From Dev

Website Speed Test hitting 0/100 in "Page Speed Insight"

From Dev

ProgressBar in Javafx shows only state 0 and 100% while copying file

From Dev

Cassandra only one row is inserted when expected 100k

From Dev

Progressbar when load activity

Related Related

  1. 1

    Zlib::BufError when using progressbar/ruby-progressbar gem

  2. 2

    Prevent Error Message from Appearing When Hitting Cancel of Opening a File

  3. 3

    moving a circle backward when hitting the canvas x border

  4. 4

    jQuery: add line break at cursor position when hitting Enter

  5. 5

    How to define a nested route to render when hitting the parent in Ember

  6. 6

    Body lost a velocity component when hitting a wall

  7. 7

    curl vs python "requests" when hitting APIs

  8. 8

    What to do when hitting the queue size of slick?

  9. 9

    Stop default Autocomplete behavior when hitting spacebar in Visual Studio 2015

  10. 10

    Scanner loop doesn't cycle when hitting enter twice

  11. 11

    How to kill Android app 100% when hitting Back

  12. 12

    Show response everytime when hitting the api in volley

  13. 13

    gvim produces error when hitting the close window

  14. 14

    How to shutdown the computer when hitting the Power button?

  15. 15

    What does WorkManager do with jobs after hitting JobScheduler limit of 100?

  16. 16

    How to shutdown the computer when hitting the Power button?

  17. 17

    Vim tab size when hitting <Tab> and when autoindent applies

  18. 18

    VMWare Workstation CPU Usage hitting 100%

  19. 19

    SpriteKit Jumping when hitting Ground

  20. 20

    Android ProgressBar not updating as expected?

  21. 21

    Zlib::BufError when using progressbar/ruby-progressbar gem

  22. 22

    Firefox - width: 100% not working as expected

  23. 23

    AVAudioPlayer not resuming when hitting stop button

  24. 24

    What to do when hitting the queue size of slick?

  25. 25

    ProgressBar in AsyncTask is showing values more 100

  26. 26

    Website Speed Test hitting 0/100 in "Page Speed Insight"

  27. 27

    ProgressBar in Javafx shows only state 0 and 100% while copying file

  28. 28

    Cassandra only one row is inserted when expected 100k

  29. 29

    Progressbar when load activity

HotTag

Archive