Skip to main content
GameDev.net gamedev.net
🔒 Locked

SetThreadPriority

Started by Zenroth Dec 21, 1999 at 2:45 PM 4 replies 1.5k views
Original Post
Zenroth
Zenroth
Please help me out here ive been looking at msdn ,and my compiler docs for 2 days now.
How do you set the handle for SetThreadPriority()
Ive tried using my hwnd,ive tried
well about 5 differnt ways. I just want to increase my main process priority.
mordell
mordell

Zenroth,

SetThreadPriority accepts the HANDLE to a thread, and an integer specifying the priority level.

An HWND is not a valid parameter to the SetThreadPriority function.

If you are looking at using the handle to the thread you are currently in, try using GetCurrentThread.

HTH,

-mordell

__________________________________________

Yeah, sure... we are laughing WITH you ...
Gromit
Gromit
code:

HANDLE hProc=GetCurrentProcess();
SetPriorityClass(hProc,REALTIME_PRIORITY_CLASS);

William Reiach - Human Extrodinaire

Marlene and Me

Zenroth
Zenroth
Thanks a million Gromit i had tryed
SetPriorityClass(GetCurrentProcess,REALTIME_PRIORITY_CLASS);

But it hadnt worked guess i have to make a handle and call GetCurrentProcess(); on it. Anyways thanks alot.

mhkrause
mhkrause
Be careful setting real-time priority, you may interfere with Windows background tasks (like clearing disk buffers.)

Also, you may find that this will not help much on a single-threaded app.

Typically, your application is taking 99% of the CPU time anyway. Don't count on switching your process's priority to cause a huge speedup.

Rock2000
Rock2000
Just to be clear, since I see both here, there are two separate (but intertwined) ways to change priority. SetPriorityClass() and SetThreadPriority(). Class sets the base priority, and thread changes it relative to the Class. There is a list in the MS help somewhere of how the different combinations add up relative to other combinations. But it is not a good idea to use the realtime priorities. Use HIGH and HIGHEST. It avoids Window's sometimes butting in, but allows it to do any mandatory stuff it needs to.

Rock

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.