How to change the application priority  
Author Message
Jan Byvaly





PostPosted: .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





PostPosted: .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





PostPosted: .NET Base Class Library, How to change the application priority Top

Simply, just select priority column to display in the Task Manager.
 
 
Jan Byvaly





PostPosted: .NET Base Class Library, How to change the application priority Top

Sorry, noone have idea why increasing the priority is not working, please
 
 
RizwanSharp





PostPosted: .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





PostPosted: .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





PostPosted: .NET Base Class Library, How to change the application priority Top

I'm feeling really lazy to write right now so please have a look on it yourself here:

http://www.cafeaulait.org/course/week11/02.html

http://www.google.com/search sourceid=ie7&rls=com.microsoft:en-US&ie=utf8&oe=utf8&q=Process+vs+thread

Best Regards,



 
 
Jan Byvaly





PostPosted: .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





PostPosted: .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,



 
 
????? ????????





PostPosted: .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





PostPosted: .NET Base Class Library, How to change the application priority Top

Thank you Nenad, that's it!
 
 
VisuallyImpared





PostPosted: .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.