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

660
Views
The name 'Thread' does not exist in the current context

When I put this code Thread.Sleep(2000); it gives me the error:

The name 'Thread' does not exist in the current context`.

I already included the namespace using System.Threading;. See System.Threading.Thread.Sleep() on MSDN.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I'm guessing it's a Portable Class Library or Windows Store/Phone project targeting the Windows Runtime that doesn't have such a construct.


An alternative and recommended way would be to use:

await Task.Delay(TimeSpan.FromSeconds(2));

or for a blocking call in case it's not in an async context:

Task.Delay(TimeSpan.FromSeconds(2)).Wait();

A similar problem is also presented in this post.

over 4 years ago · Santiago Trujillo Report

0

Try using the full namespace in your code:

 System.Threading.Thread.Sleep(1000);
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!