none
CPU Usage RRS feed

  • Question

  •  

    for some reason, and everything is on background worker that does much, my program still uses 100% of my cpu no matter what due to the fact that my timer has interval of 1 instead of like 1 second.

     

    how do i make it use up at max 10%?

    Sunday, March 16, 2008 12:24 AM

Answers

All replies

  • if not the usage, at least I would need to change its priority to low.

    Sunday, March 16, 2008 12:43 AM
  • Do you talk about the task manager?

    The windows task manager displays cpu usage of processes. If you start your program the windows system will create a process for it. All threads started within this program/process will account on this process too. So if your background threads will do heavy work your process in the task manager will show high cpu usage too, no matter what your foreground thread is doing.

     

    regards

    Philipp

    Sunday, March 16, 2008 1:06 PM
  •  

    I want it to do low priority in task manager.

     

    If also I could limit it to being able to only use a max of 10% under task manager, that would be great.

    Sunday, March 16, 2008 5:45 PM
  • higher priority means that if there is a thread/process with higher priority it will get the cpu to work with. If nobody else demands access to your cpu why not give your working thread all that's available. The windows system will check time by time if a higher priority thread requests access to the cpu. Even if your thread will not give up, the windows system will withdraw the cpu from it in order to service a higher priority demand. If this wouldn't be true you can't open the task manager to monitor cpu utilization.

    So what's excatly your problem?

     

    regards

    Philipp

    Sunday, March 16, 2008 5:58 PM
  •  

    I want to set my program to low priority instead of regular priority so that all other applications take the more cpu.

     

    I don't want to set them to high priority because i want all other programs, and not just some to be taking priority over it.

    Sunday, March 16, 2008 8:44 PM
  • I have to apologize. I tried to find out how the set the priority of backgroundworker, but that's seams to be impossible.

    I found another forum post which says the same

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=946112&SiteID=1

    It looks like you have to program a thread to be able to set the priority.

     

    Sorry

    Philipp

    Sunday, March 16, 2008 10:15 PM
  • If you want to change the priority by an external tool like the task manager, you should look at

    http://technet.microsoft.com/en-us/sysinternals/default.aspx

    I know they have a tool (procmon) to list the threads within a process, but I don't know if you can change the priority with one of the tools.

     

    regards

    Philipp

    Sunday, March 16, 2008 10:25 PM
  • Try something like this:

     

    Code Snippet

    MsgBox(System.Threading.Thread.CurrentThread.Priority.ToString)

    System.Threading.Thread.CurrentThread.Priority = _

        Threading.ThreadPriority.BelowNormal

    MsgBox(System.Threading.Thread.CurrentThread.Priority.ToString)

     

     

    Sunday, March 16, 2008 11:11 PM