I wrote a .NET app that spawns a thread that loops endlessly as it checks to make sure that some conditions are true. Task Manager reveals that the moment this thread is spawned, the application uses almost all the CPU resources available, for as long as the thread runs, which is the lifetime of the application.
How can this thread be prevented from using so much CPU resources?
Use Monitors if you have to wait for data from other threads:
http://msdn.microsoft.com/de-de/library/system.threading.monitor%28v=vs.80%29.aspx
if that’s not possible, you can consider adding a sleep of, for example 10ms, within the while loop.
This should help.
See also the following related post: Thread.Sleep or Thread.Yield