Jump to content

  • Log In with Google      Sign In   
  • Create Account

SetThreadPriority


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Zenroth   Members   -  Reputation: 127

Like
Likes
Like

Posted 21 December 1999 - 08:45 AM

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.

Sponsor:

#2 mordell   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 December 1999 - 08:50 AM


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



#3 Gromit   Members   -  Reputation: 144

Like
Likes
Like

Posted 20 December 1999 - 09:11 AM

code:

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



#4 Zenroth   Members   -  Reputation: 127

Like
Likes
Like

Posted 20 December 1999 - 11:43 AM

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.


#5 mhkrause   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 December 1999 - 01:03 PM

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.



#6 Rock2000   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 December 1999 - 08:45 AM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS