I have the following code:
int i = 5000;
Console.WriteLine("waiting" + i + "miliseconds");
System.Threading.Thread.Sleep(i);
i = 3000;
Console.WriteLine("waiting" + i + "miliseconds");
System.Threading.Thread.Sleep(i);
Console.WriteLine("finish");
During the sleep my program doesn’t respond. How can sleep be translated into the timer functions?
Well… yeah, that’s what you’re telling it to do. You’re suspending the main thread, so how could it possibly do anything other than wait?
If you want to launch a background thread or timer you will need to use one of those classes. You do not explain what you are actually trying to accomplish here, so the best advice I can give is to go look up some example code for the
BackgroundWorkerorTimerclasses (there are a fewTimerclasses, chose the one that best fits what you are trying to do).