tags:

views:

466

answers:

2

I'm making a C# program, in my program, its call another program. The problem is the program that I called, its consume 100% of CPU. So I want to limit it to a const percentage of CPU usage. Its is posible and plz show me how. Thank you.

+4  A: 

Is there any reason why you want to limit it to a specific percent of CPU usage? What about running it in lower priority, so that it still uses 100% of the CPU when nothing else requires it but gets put in the background when there are more important processes running?

Tal Pressman
This still gives server admins the ability to control distribution of processing. While the CPU is not being used, it could be a good idea to give it 100%.
Russell
So good answer Tal :)
Russell
It's ok to run the the CPU 100% 24/24?
Mr.Bua
The CPU is there to process things... There's no reason not to use it. Of course, you should make sure there are no bugs causing you to "waste" CPU time, keeping it at 100% even though there's nothing useful happening, but other than that there's usually no reason to limit CPU usage.
Tal Pressman
A: 

The operating system should handle the time sharing between your two applications. There is probably a good reason your application is using 100% of the CPU, it is calculating something. If you need to wait for the completion of another process then you can use Process.WaitForExit to halt the execution of the calling thread while the other process completes.

stimms