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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:36:41+00:00 2026-05-26T23:36:41+00:00

I have a Form with a Label with text Loading. label1.Text = Loading…; In

  • 0

I have a Form with a Label with text “Loading”.

label1.Text = "Loading...";

In Form.Load I have a new Thread which is doing something, lets say this.

void Form_Load(object sender, EventArgs args)
{
   Thread t = new Thread(run);
   t.Start();
}  

void run()
{
   for(int i = 0; i < 1000000; i++)
   {

   }
}

I want to change label1.Text property to “Finished” after the completion of Thread “t”. But where and how to change I don’t have any idea. I am learning Threads. Do I have to create one more thread to do this which continouously checks the isAlive property of Thread “t”?

  • 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-26T23:36:41+00:00Added an answer on May 26, 2026 at 11:36 pm

    You have multiple solution. If you really want to use the Thread class, you can call the Join method, but this will block the UI thread which is not a good thing. You could also call the Invoke method of your form right after your “for” loop as so

    void run()
    {
        for (int i = 0; i < 100000000; i++)
        {
        }
    
        this.Invoke(new Action(() => this.label1.Text = "done"));
    }
    

    The invoke method is required because you are in a windows form and the invoke method will execute your code on the UI thread.

    Instead of using the Thread class, you could also have a look at Delegate.BeginInvoke and at System.Threading.Tasks. They are both more efficient since it pool the threads and the provide callback to separate your tear-down code.

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

Sidebar

Related Questions

Let's say I have an html form. Each input/select/textarea will have a corresponding <label>
The fields in my form have a label, some help text, some example text,
I have Windows Form application and a label which is databound based on a
I have a form element defined as: <div class=field> <div class=name> <label for=User_LastName> Last
I have set the form decorators in this way: <?php $this->setElementDecorators(array( 'Label', array(array('labelTd' =>
i have a label in my form, and im trying to get the value
I have a label that is using a repeater to get information form a
I have a really simple search form with the following Label (Search) Textbox (fixed
When I have many controls on a Form (i.e. Label, Button etc) that do
I have an upload box... <form action=upload_file.php method=post enctype=multipart/form-data><BR> <label for=file>Filename:</label><BR> <input type=file name=file

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.