Thread Priority

G

Guest

My Windows Form app needs a lower priority. With VS.NET 2003, I could do
something like:
System.Threading.Thread.CurrentThread.Priority =
System.Threading.ThreadPriority.Lowest;

This still compiles in VS.NET 2005 Beta 1 and Beta 2, but has no apparent
effect on the actual priority.

I've set this in Program.cs as well as the form itself, thinking I might've
treated the wrong thread...all to no avail.

Is there a different way to do this in .NET2?

Thanks!
 
W

Willy Denoyette [MVP]

Chris Crabtree said:
My Windows Form app needs a lower priority. With VS.NET 2003, I could do
something like:
System.Threading.Thread.CurrentThread.Priority =
System.Threading.ThreadPriority.Lowest;

This still compiles in VS.NET 2005 Beta 1 and Beta 2, but has no apparent
effect on the actual priority.

I've set this in Program.cs as well as the form itself, thinking I
might've
treated the wrong thread...all to no avail.

Is there a different way to do this in .NET2?

Thanks!

Works for me, the base priority of the main (UI) thread is set to 6, while 8
= normal. How are you looking at the thread priority? I'm also not clear on
why you need this for, there is in general no need to change the thread
priority of a foreground process and certainly not the UI threads priority.

Willy.
 
G

Guest

Thanks for the response, Willy.

I am looking at the priority through the Processes tab in Task Manager. I
context-click, choose Set Priority and notice which option is marked. It
remains marked 'Normal' despite the code we discussed. I can of course
manually mark it as 'Low' within Task Manager, but this quickly becomes
tiresome and if I need it to run with Low priority on a user's machine, Task
Manager isn't really a good solution.

How are you checking the priority so that you see it as a 6?

As to why I would want to do this, it comes up quite a bit.

For example, if I am running a full suite of test cases through an app, it
takes anywhere from ten minutes to overnight depending on what I am doing
exactly. I need to be able to work effectively on other things while this is
running, so this seems to be exactly what priorities are for.

Another example is a file comparison/copy operation that I need to run on a
user's machine. It will take a while just by the nature of the amount of data
involved. In this case I definitely need the app to play with other apps on
the user's system. Especially so here because the user may not even have
permissions to modify the process priority, even if I were inclined to show
him how (which I am not :)).

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top