Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Windows Show Desktop causes WinForms elements to stop updating

Is there a simple way to have elements on a form keep updating even after I click on Windows Show Desktop? The following code updates the value in textBox1 until I click on Windows Show Desktop (Windows 10 - click on the bottom right of the screen). I prefer not to use Application.DoEvents().

void Button1Click(object sender, EventArgs e)
{
    int n = 0;
    while(true) {
        textBox1.Text = n++.ToString();
        textBox1.Refresh();
        Update();
        // Application.DoEvents();
        Thread.Sleep(200);
    }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Using Thread.Sleep blocks the current thread (UI thread); you can fix it like this:

private async void button1_Click(object sender, EventArgs e)
{
    int n = 0;
    while (true)
    {
        textBox1.Text = n++.ToString();
        await Task.Delay(200);
    }
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!