[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?:confused:
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.
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
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.
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.
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...
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
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:
Dim p() As Process = Process.GetProcessesByName("notepad")
If p.Length > 0 Then
p(0).PriorityClass = ProcessPriorityClass.RealTime
End If
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!
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.
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
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. :ehh:
Re: [2008] How to change the Priority of any running Process?
Ya
I know... Ended up making my own code... lol Problem Solved