Reputation: 205
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
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