I'm trying to execute a long-running piece of code in a "background" thread and by "background" I mean low-priority thread not .NET background term. I created a thread, set its priority to Lowest and still 100% CPU is used if no other threads are running. The situation improves when I manually call Thread.Sleep(1) but I don't want to change my code and controlling CPU utilization via Thread.Sleep is highly unaccurate.
I want some way of executing a piece of code which will be throttled to ensure CPU usage at 5%-10%. Also I don't want to change the code too much (it is quite complex).
Is it possible?