xtd 0.2.0
Loading...
Searching...
No Matches

◆ priority_class() [2/2]

process & xtd::diagnostics::process::priority_class ( xtd::diagnostics::process_priority_class  value)

Sets the overall priority category for the associated process.

Parameters
valueThe priority category for the associated process, from which the xtd::diagnostics::process::base_priority of the process is calculated.
Exceptions
xtd::invalid_operation_exceptionThere is no process associated with this xtd::diagnostics::process object.
Remarks
The value returned by this property represents the most recently refreshed priority of the process. To get the most up to date priority, you need to call xtd::diagnostics::process::refresh() method first.
A process priority class encompasses a range of thread priority levels. Threads with different priorities that are running in the process run relative to the priority class of the process. Win32 uses four priority classes with seven base priority levels per class. These process priority classes are captured in the xtd::diagnostics::process_priority_class enumeration, which lets you set the process priority to xtd::diagnostics::process_priority_class::idle, xtd::diagnostics::process_priority_class::normal, xtd::diagnostics::process_priority_class::high, xtd::diagnostics::process_priority_class::above_normal, xtd::diagnostics::process_priority_class::xtd::diagnostics::process_priority_class::below_normal, or xtd::diagnostics::process_priority_class::real_time. Based on the time elapsed or other boosts, the base priority level can be changed by the operating system when a process needs to be put ahead of others for access to the processor. In addition, you can set the xtd::diagnostics::process::priority_boost_enabled to temporarily boost the priority level of threads that have been taken out of the wait state. The priority is reset when the process returns to the wait state.
The xtd::diagnostics::process::base_priority property lets you view the starting priority that is assigned to a process. However, because it is read-only, you cannot use the xtd::diagnostics::process::base_priority property to set the priority of a process. To change the priority, use the xtd::diagnostics::process::priority_class property, which gets or sets the overall priority category for the process.
The priority class cannot be viewed using System Monitor. The following table shows the relationship between the xtd::diagnostics::process::base_priority and xtd::diagnostics::process::priority_class values.
Windows base_priority macOS base_priority linux base_priority priority_class
4 PRIO_MIN (-20) PRIO_MIN (-20)  xtd::diagnostics::process_priority_class::idle
6 PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10) PRIO_MIN + (PRIO_MAX - PRIO_MIN) / 4 (-10)  xtd::diagnostics::process_priority_class::below_normal
8 PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0) PRIO_MIN + (PRIO_MAX - PRIO_MIN)/2 (0)  xtd::diagnostics::process_priority_class::normal
10 PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10) PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 4 (10)  xtd::diagnostics::process_priority_class::above_normal
13 PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15) PRIO_MAX - (PRIO_MAX - PRIO_MIN) / 8 (15)  xtd::diagnostics::process_priority_class::high
24 PRIO_MAX (20) PRIO_MAX (20)  xtd::diagnostics::process_priority_class::real_time