Board index » Visual Studio » Set my own priority

Set my own priority

Visual Studio142
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


-
 

Re:Set my own priority

Hi Tom,



Here a link, do not become afraid, for your current application thread it is

just



threading.ThreadPriority.BelowNormal



http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfsystemthreadingthreadpriorityclasstopic.asp



I hope this helps?



Cor





-

Re:Set my own priority

* "Tom Scales" <tomtoo@softhome.net>scripsit:

Quote
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'.



--

Herfried K. Wagner [MVP]

<www.mvps.org/dotnet>">www.mvps.org/dotnet>

-

Re:Set my own priority

' 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



"Tom Scales" <tomtoo@softhome.net>wrote in message

Quote
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









-

Re:Set my own priority

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?





"Cor" <non@non.com>wrote in message

Quote
Hi Tom,



Here a link, do not become afraid, for your current application thread it

is

just



threading.ThreadPriority.BelowNormal





http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfsystemthreadingthreadpriorityclasstopic.asp



I hope this helps?



Cor









-

Re:Set my own priority

Ah, that's what I was missing.



Thanks!



Tom

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at>wrote in message

Quote
* "Tom Scales" <tomtoo@softhome.net>scripsit:

>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'.



--

Herfried K. Wagner [MVP]

<www.mvps.org/dotnet>">www.mvps.org/dotnet>





-

Re:Set my own priority

Quote


Am I missing something?



Yes, this is for the thread in the class, so if it is in your main

application, your main application thread. Let say in form1.



Quote
>Here a link, do not become afraid, for your current application thread

it

is

>just

>

>threading.ThreadPriority.BelowNormal

>

>



http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpref/html/frlrfsystemthreadingthreadpriorityclasstopic.asp

>

>I hope this helps?

>

>Cor

>

>









-

Re:Set my own priority

* "Tom Scales" <tomtoo@softhome.net>scripsit:

Quote
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).



--

Herfried K. Wagner [MVP]

<www.mvps.org/dotnet>">www.mvps.org/dotnet>

-

Re:Set my own priority

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.





-

Re:Set my own priority

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.





"Tom Scales" <tomtoo@softhome.net>wrote in message

Quote
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









-

Re:Set my own priority

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

"Trev Hunter" <hunter_trev@hotmail.com>wrote in message

Quote
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.





"Tom Scales" <tomtoo@softhome.net>wrote in message

news:fqSdnetgkK84Gb7dRVn-iQ@comcast.com...

>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

>

>









-