Set my own priority

  • Thread starter Thread starter Tom Scales
  • Start date Start date
T

Tom Scales

I've got a long running, intensive application that I am writing. I'd like
to set my own Priority. Most of the time I want to lower it so I don't eat
up the entire processor.

I know how to do it with a thread, but how about to myself (so to speak)?

Thanks,

Tom
 
* "Tom Scales said:
I've got a long running, intensive application that I am writing. I'd like
to set my own Priority. Most of the time I want to lower it so I don't eat
up the entire processor.

I know how to do it with a thread, but how about to myself (so to speak)?

'System.Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.Lowest'.
 
' Change the priority of the application's thread.
Sub SetAppPriority( _
ByVal Thread As System.Threading.Thread, _
ByVal NewPriority As System.Threading.ThreadPriority)
' Change the priority of the specified thread
' ThreadPriority is one of:
' AboveNormal
' BelowNormal
' Highest
' Lowest
' Normal
'
Thread.Priority = NewPriority

End Sub
 
I know how to do that, but it is for a thread. I want to do it to 'myself'
or the main application. I don't want to spawn a new thread.

Am I missing something?
 
Ah, that's what I was missing.

Thanks!

Tom
Herfried K. Wagner said:
speak)?

'System.Threading.Thread.CurrentThread.Priority = Threading.ThreadPriority.Lowest'.
 
* "Tom Scales said:
I know how to do that, but it is for a thread. I want to do it to 'myself'
or the main application. I don't want to spawn a new thread.

You can do it for the current thread (see my other reply).
 
Hi,

Your main application IS a thread (usually, STAThread, but still a thread).

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 
In addition to what the others have mentioned about
System.Threading.Thread.CurrentThread.Priority (which lets you set the
priority of the current thread), have a look at
System.Diagnostics.Process.GetCurrentProcess.PriorityClass. This lets you
set the priority for your process (which affects all threads in your
application). You can see the change in task manager if you right click on
your process and select "Set Priority".

HTH,

Trev.
 
Thanks to all! I finally have it figured out. I will try the Priority class
too.

Don't know why this split into two threads -- just posted once.

Tom
 
Back
Top