Control the CPU Utilization during Application Execution written C#.Net

A

apondu

Hi,

This is Govardhan, i am working on C#.Net.

I have a problem and i am sure most of them would have come across
this

problem. I have written a application in C#.Net. It does lot of work
so i know

it'll take time for the execution. But my problem is it starts
utilizing 98 to

100% of the CPU. I needed to know is there any way where in i can
control the

amount of CPU utilization for my application and restrict it to use
say some 60

-70% of the CPU. Actually when it starts utilizing 98 to 100% of the
CPU, i get

a feel that my system is hung-up, so i wanted to avoid this.

Is there any other solution to this problem.

If someone knows the solution for this problem then can u share it.

I am waiting for the response, this is my mail-id (e-mail address removed)

Thanks for the help and suggestions.

Regards,
Govardhana.
 
G

Guest

Well you set the thread's priority to BelowNormal / Lowest.

Alternatively do not execute tight loops and call Thread.Sleep(milliseconds)
 
A

apondu

Hi,

I have done tht, even thn the cpu utilization is 100%. Is there any
other solution for this...

Thanks for the response

Regards,
Govardhana
 
H

Henning Krause [MVP - Exchange]

Hello,

lowering the thread/process priority will not stop the process from using
all available cpu cycles. But if another program runs at a higher priority,
it will get relative more cpu cycles than your app.

Best regards,
Henning Krause
 
G

Guest

As Henning said, using thread priority is not going to stop 100% CPU usage.
It just means that if there is any other thread / program that is running at
a higher priority then it will get precedence.

The only other thing is to make sure you do not use tight loops and use
Thread.Sleep(timeInMilliseconds)
 
G

Guillaume Charhon

Maybe if you change the priority of the actual thread, it can solve your
problem...

Regards.

apondu a écrit :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top