By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Setting thread priority to low(est)

P: n/a
I have a couple of small single-thread Console utilities doing cpu-intensive
stuff. Is there an easy way to set the program execution priority to LOW
from within the program ? Now I pause the things first and invoke
TaskManager and manually set the priority... A bit cumbersome.
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
MJB
I don't think there is. You may want to execute the worker code in a
separate thread; that way you can control the priority. Good luck.
"Stu Banter" <x2**************@westerterp.com> wrote in message
news:3f***********************@news.xs4all.nl...
I have a couple of small single-thread Console utilities doing cpu-intensive stuff. Is there an easy way to set the program execution priority to LOW
from within the program ? Now I pause the things first and invoke
TaskManager and manually set the priority... A bit cumbersome.

Nov 15 '05 #2

P: n/a
Use the Process class to GetCurrentProcess. Then use that process's
public property PriorityClass to set the priority of the process.

"Stu Banter" <x2**************@westerterp.com> wrote in message
news:3f***********************@news.xs4all.nl...
I have a couple of small single-thread Console utilities doing cpu-intensive stuff. Is there an easy way to set the program execution priority to LOW
from within the program ? Now I pause the things first and invoke
TaskManager and manually set the priority... A bit cumbersome.

Nov 15 '05 #3

P: n/a
Hi,

Take a look at Process class, here you have a PriorityClass property that
you may use for it.

Also try this line:
Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Stu Banter" <x2**************@westerterp.com> wrote in message
news:3f***********************@news.xs4all.nl...
I have a couple of small single-thread Console utilities doing cpu-intensive stuff. Is there an easy way to set the program execution priority to LOW
from within the program ? Now I pause the things first and invoke
TaskManager and manually set the priority... A bit cumbersome.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.