1

I am having C# run a process in a new thread. The process takes 95 - 100% of my CPU. Is there a way I can tell the process to use less CPU? Do I need to tell the thread to do less CPU or the process?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user2475310
  • 733
  • 4
  • 13
  • 19
  • What computations are you doing in the new thread that might be causing your issue? Posting code may help to clarify this. –  Jul 23 '13 at 01:51
  • Possible duplicate http://stackoverflow.com/questions/989281/how-can-i-programmatically-limit-my-programs-cpu-usage-to-below-70 – Martheen Jul 23 '13 at 01:54
  • What do you mean, "in a separate thread"? By definition, any new process will run on a new thread. – John Saunders Jul 23 '13 at 03:09

1 Answers1

3

There's no direct way to say "use less CPU". It seems like your operation is CPU Bound

The best way to keep the CPU from being constantly burning at 100% utilization, is to invoke some direct threading control. Put your main unit of work in a thread and call Thread.Sleep after a unit of work has been executed. As part of setting up a thread you can also use Thread.Priority to set the priority (as you would via Task Manager).

gudatcomputers
  • 2,822
  • 2
  • 20
  • 27