Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8711769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:57:55+00:00 2026-06-13T04:57:55+00:00

What am I missing here while attempting to calculate the percentage complete? My percentage

  • 0

What am I missing here while attempting to calculate the percentage complete? My percentage equation seems to return an incorrect percentage.

Int32 counter = 0;

foreach (var vehicle in vehicles)
{
    counter += 1;

    Int32 percentage = (Int32)((double)counter * vehicles.Count()) / 100;

    _worker.ReportProgress(percentage);


    if (_worker.CancellationPending)
    {
        e.Cancel = true;
        _worker.ReportProgress(0);
        return;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:57:56+00:00Added an answer on June 13, 2026 at 4:57 am

    To work out percentages you should be doing

    progress
    --------  x 100
     total
    

    You are doing

    progress x total
    ----------------
           100
    

    Try using (counter * 100) / vehicles.Count() instead.

    Note: If you do the multiplication by 100 before the division it means you don’t need to mess about with casts to floats / doubles, however it does mean that all of your percentages are rounded down. If you want a more precise percentage then cast to doubles and don’t worry about the order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must be missing something basic here but while developing a custom jQuery widget,
Am I missing something here while creating table using sqlalchemy? from sqlalchemy import create_engine
What am I missing here? This is the error I am getting... error: type
Wondering what I'm missing here. Relatively new to C and iOS development, so please
What am I missing here? I am using the haml_scaffold generator and the pages
What am I missing here? ViewModel: public class ViewModel { public IDictionary<int, string> Entities
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid
Is there some trick that I'm missing here? I've created a templated control, very
I am not sure what I'm missing here so I'll try to explain a
I'm sure there's something obvious I'm missing here, but I know that popover controls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.