user007
user007

Reputation: 205

How to sleep one thread while other threads is working in visualC#?

I want to make two threads like thread1 and thread2

and individually control them but when I do thread1.Sleep(1000), it gives an error.

Member 'System.Threading.Thread.Sleep(int)' cannot be accessed with an instance reference; qualify it with a type name instead

How can I do this?

Upvotes: 1

Views: 1021

Answers (1)

Kayani
Kayani

Reputation: 972

Call the Thread.Sleep(1000) in the function that is being executed by thread1.

For example you have :

Thread thread1 = new Thread(MyFunction);
thread1.Start();

than in MyFunction call the Thread.Sleep(1000);

Upvotes: 2

Related Questions