Share via


SetThreadPriority

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function sets the priority value for the specified thread.

Syntax

BOOL SetThreadPriority(
  HANDLE hThread,
  int nPriority
);

Parameters

  • hThread
    [in] Handle to the thread whose priority value is to be set.
  • nPriority
    [in] Specifies the priority value for the thread.

    The following table shows possible 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.

    Note

    The priority levels zero through 7 that were available in earlier versions of Windows Embedded CE are now mapped to priority levels 248 through 255. These symbolic priority names should only be used with SetThreadPriority, and not with CeSetThreadPriority.

Return Value

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

Remarks

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

This function enables setting the base priority level of a thread without considering priority classes.

Threads are scheduled in a round-robin fashion at each priority level. Threads at a lower level are only scheduled when no executable threads exist at a higher level.

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, be sure a high-priority thread does not consume all available CPU time.

For more information about priority levels in Windows Embedded CE, see Priority Levels.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Process and Thread Functions
GetThreadPriority
CeSetThreadPriority