Yeah, on windoze I have hit this sort of problem with Sleep() before. I always use WaitForSingleObject(GetCurrentThread(),MIN_YIELD_TIME); instead of Sleep() now, much better response and you can control the minimum yield time with better granularity.
The problem has also shown up with low but non-zero Sleep() times because you cannot predict what the scheduler will do even if your app is the only USER process running.
Threading question
Quote:Original post by MCeltic33Unless you need to do other idle processing that is non-blocking, yes.Quote:Original post by Evil Steve
Your program will use 100% of the CPU unless it yields to the OS through Sleep() or some blocking call like WaitForSingleObject or GetMessage().
Is your application a windows based one or a console based one? If it's a windows based one, you could use GetMessage() instead of PeekMessage() in your window processing loop to still remain responsive and use 0% of the CPU when you're not doing anything.
It is a windows based application - would you recomend using GetMessage() in every form of the application?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement