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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:47:38+00:00 2026-06-08T02:47:38+00:00

I got a problem with my textbox. I have a class that represents the

  • 0

I got a problem with my textbox.
I have a class that represents the GUI thread and a class for the worker thread that does some networking stuff and then has to add the log to the textbox in the GUI thread so you can see what is happening in the background.
However, I have the problem that nothing happens on the GUI, only the debug information that addLine() was called is in the console.
The method addLine() that should add the log gets called but it seems like AppendText() just does nothing.
I am pretty sure this has to do something with the threads but I am not sure how I shall solve this.

Here is the code:

Worker Thread:

    Form1 form = new Form1();
    // This method gets called in the worker thread when a new log is available
    private void HandleMessage(Log args)
    {
        // Using an instance of my form and calling the function addLine()
        form.addLine(args.Message);
    }

GUI Thread:

    // This method gets called from the worker thread
    public void addLine(String line)
    {
        // Outputting debug information to the console to see if the function gets called, it does get called
        Console.WriteLine("addLine called: " + line);
        // Trying to append text to the textbox, console is the textbox variable
        // This pretty much does nothing from the worker thread
        // Accessing it from the GUI thread works just fine
        console.AppendText("\r\n" + line);

        // Scrolling to the end
        console.SelectionStart = console.Text.Length;
        console.ScrollToCaret();
    }

I tried to do some Invoke stuff already but failed at using it properly.
The GUI either locked itself or it just continued to do nothing.

  • 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-08T02:47:40+00:00Added an answer on June 8, 2026 at 2:47 am

    You can’t take to a winforms UI if you aren’t on the UI thread. Try:

    console.Invoke((MethodInvoker)delegate {
        console.AppendText("\r\n" + line);
    
        console.SelectionStart = console.Text.Length;
        console.ScrollToCaret();
    });
    

    which will bump it onto the UI thread.

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

Sidebar

Related Questions

I have defined some events when input textbox has got focus and some task
I got problem with sending data in Android using httpPost. I found some example,
I've got problem with DirectX in C#. I want to draw some lines. Firstly
have a nice day. I got problem when trying to create an image from
Previously, I have worked on local notifications, but I got problem in it now.
I have got a problem. I have windows forms application with dynamic generated layout,
I am (very) new to WPF and I have got a question regarding that.
I have a problem with events stacking up. I've got a matrix of large
I have got a textbox and Ajax autocompleteextender in my web page.I have no
I have got a problem with my code and i cant seem to fix

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.