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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:49:17+00:00 2026-06-12T14:49:17+00:00

I know how to do a thread safe update on a text box that

  • 0

I know how to do a thread safe update on a text box that was already defined http://msdn.microsoft.com/en-us/library/ms171728.aspx …. how can i do this on text boxes that were generated later on in the program? You advice is much appreciated.

  • 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-12T14:49:19+00:00Added an answer on June 12, 2026 at 2:49 pm

    Given some TextBox object, just invoke on it:

    TextBox foo = new TextBox(...);
    
    // Code to add the new box to the form has been omitted; presumably
    // you do this already.
    
    Action update = delegate { foo.Text = "Changed!"; };
    
    if (foo.InvokeRequired) {
        foo.Invoke(update);
    } else {
        update();
    }
    

    If you’re using this pattern a lot, this extension method might be helpful:

    public static void AutoInvoke(
        this System.ComponentModel.ISynchronizeInvoke self,
        Action action)
    {
        if (self == null) throw new ArgumentNullException("self");
        if (action == null) throw new ArgumentNullException("action");
    
        if (self.InvokeRequired) {
            self.Invoke(action);
        } else {
            action();
        }
    }
    

    Then you can reduce your code to:

    foo.AutoInvoke(() => foo.Text = "Changed!");
    

    This will just do the right thing, executing the delegate on the main GUI thread whether or not you are currently executing on it.

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

Sidebar

Related Questions

I want to know that is boost::asio::deadline_timer thread safe? Can somebody answer me?
I know that I must call Synchronize to update the vcl from a thread
I know that Struts 2 Actions are thread safe. But what happens if those
Is inet_aton Thread-Safe? I know according to UNP that POSIX doesn't require a lot
I know that singleton classes are inherently not thread-safe. But is there any way
So I know that NSManagedObjects are not thread safe and managedObjectIDs are, and we
I know UIView are not thread safe so i cant add a view on
So I know NSManagedObjects are not thread safe, and the best way to get
I am doing some research on developing thread safe applications. I know users can
With reference to the following link: http://docs.python.org/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe I wanted to know if the following:

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.