I am using VB9 (VS2008).
I have created a Windows service, which indexes some folders regularly.
Is there any way that I can put upper limit on CPU usage based on the current system state, that is, if the system is useless, the thread can use as much CPU as much as needed, but if If other programs / processes are running, then they should use the CPU in a manner that does not slow down the system.
You can reduce the priority of the thread, in the net by
Setting it below will be normal, this would mean that the other threads will be scheduled in front of it.
This thread may be hungry, but it seems that this is an acceptable design decision for your needs.
Note that since you are doing enough disk Io, this will actually be the main effect of the back ground function, and you feel that reducing priority is not enough (since D
A monitoring thread that checks the use of the machine (optionally only takes care of at least one interactive user present) can stop indexing (or throttle Io quite). On It will be important, where there are many available cores (and Hyper Threading Virtual Core), which means that the users are actually doing a lot of work, besides doing a lot of work to execute your indexing thread but in fact the disk Not to perform IO.
You may also want to consider whether you check to determine what you will do at that time. (Since the battery drain is not indispensable with both heavy disk access)
If you want to reduce the effect of this background IO to make more workable versions of windows from Vista to do more Add API:
This allows your code to schedule I / O less priority than other I / O
Comments
Post a Comment