SetThreadPriority

Started by
4 comments, last by Zenroth 24 years, 3 months ago

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 ...
Advertisement
code:
HANDLE hProc=GetCurrentProcess();SetPriorityClass(hProc,REALTIME_PRIORITY_CLASS);
William Reiach - Human Extrodinaire

Marlene and Me


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.

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.

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

This topic is closed to new replies.

Advertisement