is there any way to throttle the cpu usage of a windows service that is written in .NET, either inside the service code or outside. Setting the current thread to the lowest priority is not an option but as soon as exceptions start to occur the cpu load goes up, is it possible to limit this?
Asked
Active
Viewed 2,436 times
4
-
2There is no way to set the limits to a hard value in Windows (e.g. 25%). Setting thread priority is an option you should consider, however the real thing you need to do is figure out why the CPU is spiking. – Keith Adler Mar 10 '10 at 17:10
3 Answers
5
You need to take a closer look at your application. Why is it throwing exceptions, and why are those exceptions using so much CPU?

Justin Ethier
- 131,333
- 52
- 229
- 284
0
These days’ memory band-width and usage of the processor cache is as match of a problem is CPU time.
I don’t know of a OS that has kept up...
You could try using a Thread.Sleep to sleep for 50% of the wall time, messy but may work.

Ian Ringrose
- 51,220
- 55
- 213
- 317
0
If you need to control the CPU usage from outside of the code I would suggest using ThreadMaster http://threadmaster.tripod.com/ It's a little outdated but I've used it in the past and it was able to successfully resolve my issue.
This isn't ideal for a long term solution, but could be a good tool in some specific scenarios.

John
- 377
- 1
- 2
- 8