I wish my method to wait about 500 ms and then check if some flag has changed. How to complete this without blocking the rest of my application?
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.
Thread.Sleep(500)will force the current thread to wait 500ms. It works, but it’s not what you want if your entire application is running on one thread.In that case, you’ll want to use a
Timer, like so:You can set
AutoResetto true (or not set it at all) if you want the timer to repeat itself.