Results 1 to 13 of 13

Thread: [RESOLVED] [2008] How to change the Priority of any running Process?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Resolved [RESOLVED] [2008] How to change the Priority of any running Process?

    How can I change the priority of any running process within a button click?

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2008] How to change the Priority of any running Process?

    Do you mean any process within the current program, or any process on the system? In general, this is a risky thing to do. I considered it myself until I read the documentation more fully. Depending on what the process does, it looks like it could lock up your computer pretty nicely. It could certainly lock up the current app.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    Ya I know all of the things you said I read it up. I have a program that is REALLY slow when a button is clicked and I need it to just slightly speed up with a Priority change to High

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2008] How to change the Priority of any running Process?

    I don't think you'll be happy with the result. However, if the process is a thread, you might as well just set the priority to high before you start it. "Tubrocharging" an existing, running, process is even less likely to make you happy than would setting the priority to high right from the beginning.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    I know that its just that I need it for my program to run properly ive had the code before I just got a new computer and then I lost everything becasue I backed up not very much DATA.

  6. #6
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [2008] How to change the Priority of any running Process?

    I needed this for a game that was nothing special but was made explicitly to constantly consume as much CPU power as possible. All the mentioned warnings apply of course.
    Code:
            Dim Processes() As Process = Process.GetProcessesByName("NotePad.exe")
    
            Processes(0).PriorityClass = ProcessPriorityClass.Idle
            Processes(1).PriorityClass = ProcessPriorityClass.RealTime
            'etc...
    VB 2005, Win Xp Pro sp2

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    Ya that just crashes I just entered:
    Code:
            Dim Processes() As Process = Process.GetProcessesByName("NotePad.exe")
            Processes(0).PriorityClass = ProcessPriorityClass.RealTime

  8. #8
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2008] How to change the Priority of any running Process?

    Quote Originally Posted by VB6Learner
    Ya that just crashes I just entered:
    Code:
            Dim Processes() As Process = Process.GetProcessesByName("NotePad.exe")
            Processes(0).PriorityClass = ProcessPriorityClass.RealTime
    Just "notepad". Step through the code in the debugger and you'll see the PriorityClass has changed.
    vb.net Code:
    1. Dim p() As Process = Process.GetProcessesByName("notepad")
    2.  
    3. If p.Length > 0 Then
    4.     p(0).PriorityClass = ProcessPriorityClass.RealTime
    5. End If

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    Ya that just does nothing... I have had a code before that worked and it was just a single line!

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    Ya I found out what the problem was. But I am trying to get the application running for the priority to be changed.

  11. #11
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [2008] How to change the Priority of any running Process?

    Then just change the name from 'notepad' to the name of the application as it appears in the task manager's list.

    If you mean you want to fiddle with the current application, a one-liner is certainly possible.

    Process.GetCurrentProcess.PriorityClass = ProcessPriorityClass.BelowNormal
    VB 2005, Win Xp Pro sp2

  12. #12
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2008] How to change the Priority of any running Process?

    Quote Originally Posted by VB6Learner
    Ya that just does nothing... I have had a code before that worked and it was just a single line!
    Of course that does nothing if Notepad is not open.

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: [2008] How to change the Priority of any running Process?

    Ya
    I know... Ended up making my own code... lol Problem Solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width