Process.PriorityClass 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
연결된 프로세스의 전체 우선 순위 범주를 가져오거나 설정합니다.
public:
property System::Diagnostics::ProcessPriorityClass PriorityClass { System::Diagnostics::ProcessPriorityClass get(); void set(System::Diagnostics::ProcessPriorityClass value); };
public System.Diagnostics.ProcessPriorityClass PriorityClass { get; set; }
member this.PriorityClass : System.Diagnostics.ProcessPriorityClass with get, set
Public Property PriorityClass As ProcessPriorityClass
속성 값
연결된 프로세스의 우선 순위 범주이며, BasePriority 이 범주는 프로세스의 계산됩니다.
예외
연결된 프로세스 리소스에서 프로세스 우선 순위 정보를 설정하거나 검색할 수 없습니다.
-또는-
프로세스 식별자 또는 프로세스 핸들이 0입니다. (프로세스가 시작되지 않았습니다.)
원격 컴퓨터에서 실행 중인 프로세스에 PriorityClass 대 한 속성에 액세스 하려고 합니다. 이 속성은 로컬 컴퓨터에서 실행 중인 프로세스에만 사용할 수 있습니다.
프로세스를 Id 사용할 수 없습니다.
열거형에 정의된 대로 유효한 값을 사용하지 않으므로 우선 순위 클래스를 ProcessPriorityClass 설정할 수 없습니다.
예제
다음 예제에서는 메모장 인스턴스를 시작합니다. 그런 다음, 연결된 프로세스의 다양한 속성을 검색하고 표시합니다. 이 예제에서는 프로세스가 종료되는 시기를 감지하고 프로세스의 종료 코드를 표시합니다.
using System;
using System.Diagnostics;
namespace ProcessSample
{
class ProcessMonitorSample
{
public static void Main()
{
// Define variables to track the peak
// memory usage of the process.
long peakPagedMem = 0,
peakWorkingSet = 0,
peakVirtualMem = 0;
// Start the process.
using (Process myProcess = Process.Start("NotePad.exe"))
{
// Display the process statistics until
// the user closes the program.
do
{
if (!myProcess.HasExited)
{
// Refresh the current process property values.
myProcess.Refresh();
Console.WriteLine();
// Display current process statistics.
Console.WriteLine($"{myProcess} -");
Console.WriteLine("-------------------------------------");
Console.WriteLine($" Physical memory usage : {myProcess.WorkingSet64}");
Console.WriteLine($" Base priority : {myProcess.BasePriority}");
Console.WriteLine($" Priority class : {myProcess.PriorityClass}");
Console.WriteLine($" User processor time : {myProcess.UserProcessorTime}");
Console.WriteLine($" Privileged processor time : {myProcess.PrivilegedProcessorTime}");
Console.WriteLine($" Total processor time : {myProcess.TotalProcessorTime}");
Console.WriteLine($" Paged system memory size : {myProcess.PagedSystemMemorySize64}");
Console.WriteLine($" Paged memory size : {myProcess.PagedMemorySize64}");
// Update the values for the overall peak memory statistics.
peakPagedMem = myProcess.PeakPagedMemorySize64;
peakVirtualMem = myProcess.PeakVirtualMemorySize64;
peakWorkingSet = myProcess.PeakWorkingSet64;
if (myProcess.Responding)
{
Console.WriteLine("Status = Running");
}
else
{
Console.WriteLine("Status = Not Responding");
}
}
}
while (!myProcess.WaitForExit(1000));
Console.WriteLine();
Console.WriteLine($" Process exit code : {myProcess.ExitCode}");
// Display peak memory statistics for the process.
Console.WriteLine($" Peak physical memory usage : {peakWorkingSet}");
Console.WriteLine($" Peak paged memory usage : {peakPagedMem}");
Console.WriteLine($" Peak virtual memory usage : {peakVirtualMem}");
}
}
}
}
open System.Diagnostics
// Define variables to track the peak
// memory usage of the process.
let mutable peakPagedMem = 0L
let mutable peakWorkingSet = 0L
let mutable peakVirtualMem = 0L
// Start the process.
use myProcess = Process.Start "NotePad.exe"
// Display the process statistics until
// the user closes the program.
while myProcess.WaitForExit 1000 |> not do
if not myProcess.HasExited then
// Refresh the current process property values.
myProcess.Refresh()
printfn ""
// Display current process statistics.
printfn $"{myProcess} -"
printfn "-------------------------------------"
printfn $" Physical memory usage : {myProcess.WorkingSet64}"
printfn $" Base priority : {myProcess.BasePriority}"
printfn $" Priority class : {myProcess.PriorityClass}"
printfn $" User processor time : {myProcess.UserProcessorTime}"
printfn $" Privileged processor time : {myProcess.PrivilegedProcessorTime}"
printfn $" Total processor time : {myProcess.TotalProcessorTime}"
printfn $" Paged system memory size : {myProcess.PagedSystemMemorySize64}"
printfn $" Paged memory size : {myProcess.PagedMemorySize64}"
// Update the values for the overall peak memory statistics.
peakPagedMem <- myProcess.PeakPagedMemorySize64
peakVirtualMem <- myProcess.PeakVirtualMemorySize64
peakWorkingSet <- myProcess.PeakWorkingSet64
if myProcess.Responding then
printfn "Status = Running"
else
printfn "Status = Not Responding"
printfn ""
printfn $" Process exit code : {myProcess.ExitCode}"
// Display peak memory statistics for the process.
printfn $" Peak physical memory usage : {peakWorkingSet}"
printfn $" Peak paged memory usage : {peakPagedMem}"
printfn $" Peak virtual memory usage : {peakVirtualMem}"
Imports System.Diagnostics
Namespace ProcessSample
Class ProcessMonitorSample
Public Shared Sub Main()
' Define variables to track the peak
' memory usage of the process.
Dim peakPagedMem As Long = 0
Dim peakWorkingSet As Long = 0
Dim peakVirtualMem As Long = 0
' Start the process.
Using myProcess = Process.Start("NotePad.exe")
' Display process statistics until
' the user closes the program.
Do
If Not myProcess.HasExited Then
' Refresh the current process property values.
myProcess.Refresh()
Console.WriteLine()
' Display current process statistics.
Console.WriteLine($"{myProcess} -")
Console.WriteLine("-------------------------------------")
Console.WriteLine($" Physical memory usage : {myProcess.WorkingSet64}")
Console.WriteLine($" Base priority : {myProcess.BasePriority}")
Console.WriteLine($" Priority class : {myProcess.PriorityClass}")
Console.WriteLine($" User processor time : {myProcess.UserProcessorTime}")
Console.WriteLine($" Privileged processor time : {myProcess.PrivilegedProcessorTime}")
Console.WriteLine($" Total processor time : {myProcess.TotalProcessorTime}")
Console.WriteLine($" Paged system memory size : {myProcess.PagedSystemMemorySize64}")
Console.WriteLine($" Paged memory size : {myProcess.PagedMemorySize64}")
' Update the values for the overall peak memory statistics.
peakPagedMem = myProcess.PeakPagedMemorySize64
peakVirtualMem = myProcess.PeakVirtualMemorySize64
peakWorkingSet = myProcess.PeakWorkingSet64
If myProcess.Responding Then
Console.WriteLine("Status = Running")
Else
Console.WriteLine("Status = Not Responding")
End If
End If
Loop While Not myProcess.WaitForExit(1000)
Console.WriteLine()
Console.WriteLine($" Process exit code : {myProcess.ExitCode}")
' Display peak memory statistics for the process.
Console.WriteLine($" Peak physical memory usage of the process : {peakWorkingSet}")
Console.WriteLine($" Peak paged memory usage of the process : {peakPagedMem}")
Console.WriteLine($" Peak virtual memory usage of the process : {peakVirtualMem}")
End Using
End Sub
End Class
End Namespace
설명
이 속성에서 반환되는 값은 프로세스의 가장 최근에 새로 고친 우선 순위를 나타냅니다. 최신 우선 순위를 얻으려면 먼저 메서드를 호출 Refresh() 해야 합니다.
프로세스 우선 순위 클래스는 스레드 우선 순위 수준의 범위를 포함합니다. 프로세스에서 실행되는 우선 순위가 다른 스레드는 프로세스의 우선 순위 클래스를 기준으로 실행됩니다. Win32는 클래스당 7개의 기본 우선 순위 수준이 있는 4개의 우선 순위 클래스를 사용합니다. 이러한 프로세스 우선 순위 클래스는 열거형에서 ProcessPriorityClass 캡처되므로 프로세스 우선 순위를 Idle, Normal, BelowNormalHighAboveNormal또는 RealTime.로 설정할 수 있습니다. 경과된 시간 또는 기타 향상에 따라 프로세서에 액세스하기 위해 프로세스를 다른 프로세스보다 앞서야 하는 경우 운영 체제에서 기본 우선 순위 수준을 변경할 수 있습니다. 또한 대기 상태에서 제거된 스레드의 우선 순위 수준을 일시적으로 높이도록 설정할 PriorityBoostEnabled 수 있습니다. 프로세스가 대기 상태로 되돌아가면 우선 순위가 다시 설정됩니다.
이 BasePriority 속성을 사용하면 프로세스에 할당된 시작 우선 순위를 볼 수 있습니다. 그러나 읽기 전용이므로 이 속성을 사용하여 BasePriority 프로세스의 우선 순위를 설정할 수 없습니다. 우선 순위를 변경하려면 프로세스의 PriorityClass 전체 우선 순위 범주를 가져오거나 설정하는 속성을 사용합니다.
시스템 모니터를 사용하여 우선 순위 클래스를 볼 수 없습니다. 다음 표에서는 값과 값 간의 BasePriority 관계를 보여 줍니다 PriorityClass .
| BasePriority | PriorityClass |
|---|---|
| 4 | Idle |
| 8 | Normal |
| 13 | High |
| 24 | RealTime |