JoseLopez

Hello,

Is there a way to set a limit to how much of the processor power an application can utilize programmatically If so, how

Thanks in advance for your help.

Jose


Re: Visual C# General Limit Processor Usage in C#

OmegaMan

I don't want to sound trite, but a program can't go on a weight loss diet and shed processor cycles. The program presents its self to the processor as is, and the processing needs are done by the cpu. Its a measured task and that for the most part cannot be changed.

But that does not mean that he application can't minimize its impact on the processor. Here are some suggestions.
  1. In a multi-threaded application, have the thread do a sleep(1) or even a sleep(0) or even sleep (x) where x is the number of milliseconds to sleep.This will allow the thread to hand off its cycles to others. Note there are problems with using zero and 1 in the sleep, so read up on them before implementing.
  2. Write efficient code. Do you really need to assign that variable before it gets handed off No, just hand it off without assigning it. Such items can lessen the footprint of what the program requires...they may be small but in tight loops they can pay off...
  3. In a threaded application, you can specify the priority of a thread. If you know the thread is not high priority...set it to be something below the default of normal.
Those are some suggestions if you have not though about them.





Re: Visual C# General Limit Processor Usage in C#

JoseLopez

OmegaMan,

Thank you very much for your input. No, I hadn't considered your options. This gives me a good starting point.

Best regards,

Jose