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 6721821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:22:28+00:00 2026-05-26T09:22:28+00:00

I’m working on a Visual C++ application, and part of this depackitises a file,

  • 0

I’m working on a Visual C++ application, and part of this depackitises a file, sinjce this can take a while I implemented a progress bar to reflect the progress of the depackitisation.

This works fine when running with the debugger, however when I run without the debugger or from the .exe file, the progress bar consistantly gets stuck at halfway (although the program completes its function fine), and then jumps to 100%.

Through some printing of the value of the progress bar I have discovered that the value IS getting set properly, but for some reason this is not being reflected visually.

The code for the progress bar update is

while (mpeg.GetProgress() < 99){
            Console::Write(this->progressBar->Value);
            this->progressBar->Value = mpeg.GetProgress();
            this->progressBar->Update();
            Sleep(100);
        }

This is done in the programs main thread.
The sleep stops it from updating too quickly as otherwise this is impossible to follow in the console.

The function which needs tracking is mpeg.Depackitise(), this is run in a seperate thread so that the progress bar can continually be updated, the code concerning the ‘progress’ variable is :

double Mpeg::GetProgress() {
return Mpeg::progress;
}

void Mpeg::SetProgress(double prog) {
Mpeg::progress = prog;
}

The follwing code is in a for loop that goes through the entire file packet by packet. The ‘packet’ variable is the current packet and ‘packet_count’ is the total number of packets in the file, this is all done in the seperate mpeg.Depackitise() thread.

        double Percent = 0.0;

    Percent = ((double)packet / (double)packet_count);
    SetProgress(Percent * 100);

If anyone can suggest some solutions to try it would be highly appreciated, this has been annoying me for a while now. Some suggestions I found online said that use of uninitialised variables could cause differences between running with/without debug, however I can’t find any relevant variables that are uninitialised.

  • 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-05-26T09:22:28+00:00Added an answer on May 26, 2026 at 9:22 am

    You must never, ever, ever block the UI thread.

    You’re doing extensive calculations in the main thread of your application, which means its not available to answer the message pump and to draw/update drawings of controls on the screen.

    You should look into multithreading and message passing as the solution to your question. Start a thread, do the time-consuming work there, use a callback to update the progress bar of the main thread (and beware of directly accessing the UI from anything other than the main thread!).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.