Share via


SetThreadPriority

This function sets the priority value for the specified thread.

BOOL SetThreadPriority( 
HANDLE hThread, 
int nPriority); 

Parameters

  • hThread
    Handle to the thread whose priority value is to be set.
  • nPriority
    Specifies the priority value for the thread. This parameter can be one of the following values:
    Value Description
    THREAD_PRIORITY_TIME_CRITICAL Indicates 3 points above normal priority.
    THREAD_PRIORITY_HIGHEST Indicates 2 points above normal priority.
    THREAD_PRIORITY_ABOVE_NORMAL Indicates 1 point above normal priority.
    THREAD_PRIORITY_NORMAL Indicates normal priority.
    THREAD_PRIORITY_BELOW_NORMAL Indicates 1 point below normal priority.
    THREAD_PRIORITY_LOWEST Indicates 2 points below normal priority.
    THREAD_PRIORITY_ABOVE_IDLE Indicates 3 points below normal priority.
    THREAD_PRIORITY_IDLE Indicates 4 points below normal priority.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

Windows CE does not support priority classes. The order in which threads are scheduled is determined only by their thread priorities.

Threads are scheduled in a round-robin fashion at each priority level, and only when there are no executable threads at a higher level does scheduling of threads at a lower level take place.

The SetThreadPriority function enables setting the base priority level of a thread without consideration of priority classes.

All threads initially start at THREAD_PRIORITY_NORMAL (251). Use the GetThreadPriority function to get the priority value of a thread.

Use thread priority values to differentiate the relative priorities of the tasks of a process. For example, a thread that handles input for a window could have a higher priority level than a thread that performs intensive calculations for the CPU.

When manipulating priorities, ensure that a high-priority thread does not consume all of the available CPU time.

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winbase.h   Coredll.lib, Nk.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

GetLastError, GetThreadPriority

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.