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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:12:46+00:00 2026-06-08T12:12:46+00:00

I have a simple textbox in my program. Other features : another input from

  • 0

I have a simple textbox in my program.
Other features : another input from the user textbox1, and a button.
Once the user enters a value in textbox1, and presses the button, I start to check and print messages to the user. My problem is that I don’t see those messages on real time, one at a time. The messages appear at once, in the end.
I didn’t define data binding, because I thought that since it’s a simple thing, I wouldn’t need it, or am i wrong ?
This is a very small portion of my program, it’s in the button click event handler.

MainText.AppendText("Starting Refiling...\u2028");
foreach (DocumentData doc in Docs)
{
    try
    {
        wsProxy.RefileDocument(doc);
        MainText.AppendText(String.Format("Refilling doc # {0}.{1}\u2028", doc.DocNum, doc.DocVer));
    }
    catch (Exception exc)
    {
        if (exc.Message.Contains("Document is in use") == true)
            MainText.AppendText(String.Format("There was a problem refilling doc # {0}, it is in use.\u2028",doc.DocNum));
        else
            MainText.AppendText(String.Format("There was a problem refilling doc # {0} : {1}.\u2028", doc.DocNum, exc.Message));
    }
}
  • 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-08T12:12:47+00:00Added an answer on June 8, 2026 at 12:12 pm

    You’re doing all your looping/printing in the GUI thread. Basically you’re giving it new items to show and not giving it time to show them. Create a background worker and let him do the work in the foreach loop that you posted. This should allow the UI thread to update the view as the text changes, instead of getting the one update at the end with all your changes. The link I posted includes examples on how to use the backgroundworker class, but here’s what I’d do.

    Create a background worker:

    private readonly BackgroundWorker worker = new BackgroundWorker();
    

    Initialize him:

    public MainWindow()
      {
         InitializeComponent();
    
         worker.DoWork += worker_DoWork;
      }
    

    Create a task for him:

    void worker_DoWork( object sender, DoWorkEventArgs e)
    {
       // Set up a string to hold our data so we only need to use the dispatcher in one place
       string toAppend = "";
       foreach (DocumentData doc in Docs)
       {
          toAppend = "";
          try
          {
             wsProxy.RefileDocument(doc);
             toAppend = String.Format("Refilling doc # {0}.{1}\u2028", doc.DocNum, doc.DocVer);  
          }
          catch (Exception exc)
          {
             if (exc.Message.Contains("Document is in use"))
                toAppend = String.Format("There was a problem refilling doc # {0}, it is in use.\u2028",doc.DocNum);
             else
                toAppend = String.Format("There was a problem refilling doc # {0} : {1}.\u2028", doc.DocNum, exc.Message);
          }
    
          // Update the text from the main thread to avoid exceptions
          Dispatcher.Invoke((Action)delegate
          {
             MainText.AppendText(toAppend);
          });
       }
    }
    

    Start him when you get the button press event:

    private void Button_Click(object sender, RoutedEventArgs e)
      {
         worker.RunWorkerAsync();
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web application, I have users input a date in a simple textbox.
HI, I have simple application which copy text from a textbox and paste it
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
I have created a simple win 32 application..in which it has a textbox and
I'm having some trouble doing a very simple task. I have a rich textbox
I have a simple dojo text box and a value picker. I want to
Hi I have to design a Windows Form which has a simple textbox. The
I have a simple translating program i working on in vb 2010. I have
I have a simple ASP.NET page where after the initial page load the user
I have simple SL user control. A listbox which shows all customers and on

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.