What is the Best one ? Thread.Sleep() OR Timer
-
Hi, I am running something on a loop till a certain condition meets. I have two options, 1. Create a timer and execute the loop. 2. This is already running in a child thread so I can just add a while (condition) loop with Thread.Sleep() I prefer to use the second one. But I am not sure which one is the best.. Any Idea? Thanks!
Charith Jayasundara
-
Hi, I am running something on a loop till a certain condition meets. I have two options, 1. Create a timer and execute the loop. 2. This is already running in a child thread so I can just add a while (condition) loop with Thread.Sleep() I prefer to use the second one. But I am not sure which one is the best.. Any Idea? Thanks!
Charith Jayasundara
A timer is always best, sleep loops are very ugly and poor form IMO.
Christian Graus Driven to the arms of OSX by Vista.
-
Hi, I am running something on a loop till a certain condition meets. I have two options, 1. Create a timer and execute the loop. 2. This is already running in a child thread so I can just add a while (condition) loop with Thread.Sleep() I prefer to use the second one. But I am not sure which one is the best.. Any Idea? Thanks!
Charith Jayasundara
Charith Jayasundara wrote:
I am running something on a loop till a certain condition meets
Charith Jayasundara wrote:
his is already running in a child thread so I can just add a while (condition) loop with Thread.Sleep()
:confused: Thread.Sleep blocks the current thread for specified time. If your thread slept, how can you check whether the condition met or not? Your question is not clear.
Navaneeth How to use google | Ask smart questions