Reputation:
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.
Upvotes: 11
Views: 22469
Reputation: 1511
Try using the full Name Space in your code:
System.Threading.Thread.Sleep(1000);
Upvotes: 13
Reputation: 3573
I assume this is a Portable Class Library or Windows Store/Phone project targeting Windows Runtime which does not 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 you are not in an async context:
Task.Delay(TimeSpan.FromSeconds(2)).Wait();
Similar issue is also brought out in this post.
Upvotes: 13