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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:32:08+00:00 2026-05-18T00:32:08+00:00

I have a button click event and inside I do a lot of work.

  • 0

I have a button click event and inside I do a lot of work.

While I am doing this work (not from the UI project) I want to send messages to the UI to display to the user.

I am doing something like:

    void Button_Click(object sender, EventArgs e)
    {
        DoMyWork(SendMessage);
    {

    public void SendMessage(string message)
    {
        TextBox1.Text = message + "\n"; 
    }

and inside DoMyWork which is in another assembly i can call SendMessage which writes to the textbox. The messages will only display though when DoMyWork is complete.

How can I update TextBox1.Text on the fly without putting DoMyWork on a BackGround thread or do i have to put it on a BackGround thread? I do actually want to block the user from doing anything while DoMyWork is running

thanks

  • 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-18T00:32:08+00:00Added an answer on May 18, 2026 at 12:32 am

    You really need to put long running operations on a separate thread. If you do not then the UI will become unresponsive and the user will think it has hung up. There are two common ways of getting the worker thread started.

    • Use the BackgroundWorker class.
    • Create and start a Thread manually.

    There are two generally accepted methods for updating the UI safely with data generated by the worker thread.

    • Have the worker thread push the notification via Control.Invoke.
    • Have the UI thread poll a shared data structure periodically which is updated by the worker thread.

    The BackgroundWorker class inherently uses the push method (via Control.Invoke) to report progress when using the ReportProgress method in conjuction with the ProgressChanged event.

    Creating a thread manually allows you to have better control over how the UI and worker thread interactions take place in exchange for having to wire up all the plumbing yourself.

    Since I do not know the details of the long running operation nor the nature of the messages that need to be displayed I cannot say for certain direction will work best for you. Starting off with BackgroundWorker approach will probably be okay.

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

Sidebar

Related Questions

I have a button click event that takes information from controls and enters it
inside a jquery method (on a click event of a button) i have the
Suppose I have normal button.Click event. If I try to access UI elements from
I have a fairly simple code, a button click event, with the first line
I have the following code bound to the click event of a button: function
I have a problem when assigning functions to the click event of a button
I have this code in the end of link button click: Response.ContentType = application/zip;
How do i run a PHP function inside jQuery click event. I have the
I have used same command button Click event for both Insert, Update functionalities. I'm
I have code in an Update Panel and even though on a button click

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.