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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:07:28+00:00 2026-06-03T00:07:28+00:00

Explanation: Structure: Windows form – three components: Text box, Text box Response and button.

  • 0

Explanation:

Structure: Windows form – three components: Text box, Text box Response and button.

Problem: I am moving motor with C# windows form: I am starting the motor and reversing
the direction of movement of motor with single button click with 10 second delay in the middle. i.e. I start the motor, have 10 sec delay and then reverse the motor. I want to display “Start” at the beginning and “End” at the end of the 10 second delay. I have tried using thread but it does not work. But I am only able to see “Finish” not “Start” in text box. The code is below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace SampleThreadProgram
{
     public partial class Form1 : Form
     {
          static EventWaitHandle _waitHandle = new AutoResetEvent(false);
          delegate void SetTextCallback(string text);

     void SetText(string text)
     {
          if (textBox.InvokeRequired)
          {
             SetTextCallback d = new SetTextCallback(SetText);
             BeginInvoke(d, new object[] { text });
          }
          else
          {
             textBox.Text = text;
          }
     }

    void UpdateTextBox(string message)
    {
        SetText(message);
        _waitHandle.Set();
    }

    void Wait()
    {
        for (ulong i = 0; i < 10000; i++)
        {
            for (ulong j = 0; j < 100000; j++)
            {
            }
        }

    }
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {

        UpdateTextBox("Start");
        _waitHandle.WaitOne();
        Thread.Sleep(10000);
        UpdateTextBox("Finish");

    }

    }
}
  • 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-03T00:07:31+00:00Added an answer on June 3, 2026 at 12:07 am

    There’s not enough time for the UI to update. Add an Application.DoEvents(); after the SetText(message); in UpdateTextBox.

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

Sidebar

Related Questions

SICP - Structure and Interpretation of Computer Programs Explanation for the same would be
Short explanation of my problem, I need to parse an object and put its
Edit: Worked out the problem - see accepted answer for a good explanation! My
I'm searching for good explanation about making dynamic dialog --menu box in bash. I'm
I got into a problem with my classes, passing a const object (polymorphic structure)
Explanation: Say package A is always built first and then package B. I need
Explanation: i have few objects and im declaring them inside $(document).ready(). WHY? because in
Explanation I have a multidimensional array that is iterated over to created a categorized
For explanation imagine a simple address. Written in a HTML paragraph with line breaks
Quick Explanation One Silverlight (3.0) project with several XAML pages. I want to load

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.