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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:19:25+00:00 2026-05-29T07:19:25+00:00

A basic C# Problem. I have two disabled textboxes on my form, and one

  • 0

A basic C# Problem.

I have two disabled textboxes on my form, and one button. The button is currently like so:

    private void start_Click(object sender, EventArgs e)
    {
        this.two();
        this.hold();
        this.one()
    }

As you can see it calls three other methods that are like so:

  • “two” – Makes both the text boxes BackColor, black.
  • “one” – Makes just one of the boxes BackColor Black.
  • “hold”
    • Calls “System.Threading.Thread.Sleep(1000);” to pause the program for a second.
    • Changes the backcolour for both the text boxes back to white.

The problem I am encountering is that program seems to skip the first call to two. And just hold the program for a second and change one textbox to black.

Thanks for any help!

  • 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-29T07:19:26+00:00Added an answer on May 29, 2026 at 7:19 am

    What you are probably experiencing is that you are running this code on the application’s main thread, which is also responsible for responding to Windows GUI messages (like the command to repaint itself after you have changed the textboxes’ colors). The program currently does not process this message until after this event handler has completely executed, at which time only one textbox is black.

    Application.DoEvents(), as mentioned, will solve the problem by interrupting this handler and allowing the program to process the queued messages from the GUI before proceeding. Another way to do this would be to run this code in a BackgroundWorker, which would use a separate processing thread to tell the GUI thread to recolor the textboxes, while not blocking the GUI thread with the Sleep() command. Generally, using a multithreaded approach is better, as Application.DoEvents() can cause unexpected consequences by forcing the invocation of other event handlers while the current one hasn’t finished (for instance, a call to another event handler that throws an exception will throw out through the Application.DoEvents call of the one you’ve interrupted, which didn’t actually have a problem).

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

Sidebar

Related Questions

Struggling with this one. I have set up a basic email/enquiry form for a
I have a basic problem with a has_one and belongs_to association. I have two
I have two basic bar charts and I am currently using XML/SWF Charts which
I have such a basic problem in Delphi,I can't solve it. My Code: Note:DataR
So I have a rather basic javascript problem which I have been slamming my
I have a very basic texture map problem in GL on iPhone, and I'm
The problem is quite basic. I have a JTable showing cached data from a
I think I have a synchronization problem...It may be too basic..Please help.. I have
The basic problem is like this: A subscriber has successfully replicated a row from
I have two basic Cpp tasks, but still I have problems with them. First

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.