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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:02:56+00:00 2026-06-11T02:02:56+00:00

In VS 2010 I’m trying to read a text file on button click and

  • 0

In VS 2010 I’m trying to read a text file on button click and set that value as the status button value. The text file will always contain a single line with a number between 0 and 100. I’m trying to do this in C++/CLI because I’m familiar with C++ but this seems like a whole different lang! This is what I have but it causes the GUI to crash. I know it’s the loops fault but I don’t know why, what’s the best (noob) way to approach this?

    while (result<100)
    {
            StreamReader ^read=gcnew StreamReader("Status.txt");                    
            String ^x=read->ReadLine();
            read->Close();
            Int32::TryParse(x, result);
            progressBar1->Value= result;    
    }
  • 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-11T02:02:57+00:00Added an answer on June 11, 2026 at 2:02 am

    You haven’t said whether you’re using WPF or WinForms for your GUI, but this answer applies equally to either.

    If your while loop in in a button handler, that code is running on the UI thread. The UI thread is also responsible for redrawing the GUI. Since your button method isn’t returning, it’s never getting to the ‘repaint’ code, and the UI just stops.

    You didn’t mention what is writing those integers 0 to 100 to a file. If it’s another thread in the same application, there are MUCH better ways of communicating the progress between threads.

    I recommend that you replace that while loop with a Timer object of some sort. (There are appropriate classes, depending on whether you’re using WPF or WinForms.) Set the interval to something like 500 milliseconds, start the timer when your background task begins, and stop the timer when it ends. In the timer method, don’t have a while loop, just do it once.

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

Sidebar

Related Questions

Delphi 2010 has a nice set of new file access functions in IOUtils.pas (I
I'm using Excel 2010. I'm trying so save my excel file, with this code.
[2010-04-16 23:31:34 - MobileDataKeeper] Error in an XML file: aborting build. [2010-04-16 23:31:57 -
Delphi 2010, dbExpress, and SQL Server 2005 DB I am trying to make a
In Visual Studio 2010, I am trying to connect to a web service I
I have a C# 2010 application that uses Crystal Reports for VS 2010. My
2010-June-11 <remove>2010-June-2</remove> <remove>2010-June-3</remove> 2010-June-15 2010-June-16 2010-June-17 2010-June-3 2010-June-2 2010-June-1 I'm trying to find all
VS 2010 Beta Code Analysis is advising me to always dispose WCF Service Clients
VS 2010 is reporting this warning Value cannot be null. However, the project seems
In Office 2010 when a Backstage button is pressed the Backstage would automatically close.

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.