I want to be able to slow down each step in my code, it can be handy for some functions like sending keystrokes. I could add “sleep” after each step but is there a better way?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sleep is seldom a good way to do things. The right way would be to use a timer. Using a timer won’t lock up the thread and keep it from processing other events.
Put the keystrokes that you want to send into a list. Then create a timer object that sends the next keystroke available on each tick.
There are several different timer classes available. Which one to use depends on what kind of application you are creating – console, WinForms, WPF?