|
|
How to change the application priority |
|
Author |
Message |
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Hello,
i would like to change my app (main thread) priority. So i tried to:
System.Threading. Thread.CurrentThread.Priority = System.Threading.ThreadPriority.AboveNormal;
However if i run Task Manager, with priorities listed, no change is visible (priority remains normal). What am i doing wrong, please
Thank you.
.NET Development1
|
|
|
|
|
RizwanSharp
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
How can you evaluate Pripority in Task Manager. You code is fine and it has increased the priority of your application.
Best regards,
|
|
|
|
|
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Simply, just select priority column to display in the Task Manager.
|
|
|
|
|
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Sorry, noone have idea why increasing the priority is not working, please
|
|
|
|
|
RizwanSharp
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Ahhh! Ok, You are trying change the priority of a Thread which is obviously done behind the scenes but you cant view priorities on Thread level through Task Manager.
So the thing you are trying to do is possible through Process class in System.Diagnostics namespace try to iterate all system process. Find your and set its property and see what happens.
There is a property PriorityClass set it to High!
I hope it'll surely work.
Best Regards,
|
|
|
|
|
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Thank you for your kind help, could you be so kind reveal the secret of Thread and Process classes, please I thought that there's only one main-thread to be set up...
|
|
|
|
|
RizwanSharp
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
|
|
|
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Thank you, does it mean that, if i'm running single-threaded app, than Process priority equals to Thread priority, please
|
|
|
|
|
RizwanSharp
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Hmmm, I'm not sure but I dont think so that even a single threaded application has only one thread. Sorry I really dont have any precise information to tell you. You may consult some book I think I have read someever evry .Net application has 2-3 threads depending on version of .Net framework. You have to dig it up and please let me know if you are succesful to find it.
Best Regards,
|
|
|
|
|
????? ????????
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
I think this is what you are looking for..
System.Diagnostics. Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime;
Every process has a several threads.
Cmo K..
|
|
|
|
|
Jan Byvaly
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
Thank you Nenad, that's it!
|
|
|
|
|
VisuallyImpared
|
Posted: .NET Base Class Library, How to change the application priority |
Top |
I had to make a slight mod to get this to work, but otherwise a great piece of code.
My Code:
Dim MyProc As System.Diagnostics.Process = System.Diagnostics.Process.GetCurrentProcess()
MyProc.PriorityClass = System.Diagnostics.ProcessPriorityClass.High
The difference is probably just the C# vs. VB syntax.
|
|
|
|
|
|
|