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

  • Home
  • SEARCH
  • 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 3613726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:09:37+00:00 2026-05-18T22:09:37+00:00

I am setting the .Text value of a textbox , disabling it, and then

  • 0

I am setting the .Text value of a textbox, disabling it, and then calling a BackgroundWorker to do a lengthy filesystem operation. The textbox does not update with the new text value until about halfway through the BackgroundWorker operation.

What can I do to force the texbox to show the new text value ASAP? Relevant code below:

void BeginCacheCandidates()
{
    textBox1.Text = "Indexing..."; // <-- this does not update until about 20 to 30 seconds later
    textBox1.Enabled = false;
    backgroundWorker1.RunWorkerAsync();
}

void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
    //prime the cache
    CacheCandidates(candidatesCacheFileName);
}

void backgroundWorker1_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
    textBox1.Text = "";
    textBox1.Enabled = true;
    textBox1.Focus();
}

Update: I resolved the issue. It was code unrelated to this – I had overridden WndProc and it was going into a loop…

  • 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-18T22:09:38+00:00Added an answer on May 18, 2026 at 10:09 pm

    Unless there’s some detail I’m missing, wouldn’t ReportProgress give you what you want?

    void BeginCacheCandidates()
    {
        textBox1.Text = "Indexing...";
        textBox1.Enabled = false;
        backgroundWorker1.ReportProgress += new ProgressChangedEventHandler(handleProgress)
        backgroundWorker1.RunWorkerAsync();
    }
    
    void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
    {
        //prime the cache
        backgroundWorker1.ReportProgress(<some int>, <text to update>);
        CacheCandidates(candidatesCacheFileName);
    }
    
    void handleProgress(object sender, ProgressChangedEventArgs e)
    { 
        ... 
        textBox1.Text = e.UserState as String; 
        ... 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting the value of a textbox via javascript client-side. When I refresh
I have an asp.net textbox which is disabled and I am setting the value
If I am setting the Text property of a Form from a non-UI thread,
I am setting up an alert with a text field in it so players
This is the css for setting the color for h1 text that is linked:
When setting up a new virtual directory for hosting a SOAP web service in
I am having trouble databinding a TextBox.Text property to a object's method. The idea
My ASP.NET page has an <asp:TextBox /> whose text input is encoded via HttpUtility.HtmlEncode();
I have an WPF usercontrol that has a TextBox. I set the text Underline
I have a function that will change the value of a text box when

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.