VB limit itself to X CPU usage and ram usage

Hello,

i would like to know how to have a VB.net software to limit itself to X CPU usage and ram usage. How can this be done?

Thanks
gb874554Asked:
Who is Participating?
 
Corey ScheichConnect With a Mentor DeveloperCommented:
It really depends on the nature of the process.  I don't know of a way to tell an application to utilize no more than 30% CPU, but depending on what you are trying to accomplish by setting these limits you could use one of the following

Set low priority on the process so that other applications calls get run first

Process.GetCurrentProcess.PriorityClass = ProcessPriorityClass.BelowNormal
'default is normal

You can also strategically pause the process to lower cpu usage on long processes
System.Threading.Thread.CurrentThread.Sleep(50)'50 millisecond process sleep
0
 
gb874554Author Commented:
Answerd most of what i neeed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.