Process.PriorityClass 속성

정의

연결된 프로세스에 대한 전체 우선 순위 범주를 가져오거나 설정합니다.

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 열거형에 정의된 유효한 값이 사용되지 않으므로 우선 순위 클래스를 설정할 수 없습니다.

예제

다음 예제에서는 메모장의 instance 시작합니다. 그런 다음, 이 예제는 연결된 프로세스의 다양한 속성을 검색하고 표시합니다. 이 예제에서는 프로세스가 종료되는 시기를 감지하고 프로세스의 종료 코드를 표시합니다.

#using <system.dll>

using namespace System;
using namespace System::Diagnostics;
int main()
{
   
   // Define variables to track the peak
   // memory usage of the process.
   _int64 peakPagedMem = 0,peakWorkingSet = 0,peakVirtualMem = 0;
   Process^ myProcess = nullptr;
   try
   {
      
      // Start the 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( "{0} -", myProcess );
            Console::WriteLine( "-------------------------------------" );
            Console::WriteLine( "  physical memory usage: {0}", myProcess->WorkingSet64 );
            Console::WriteLine( "  base priority: {0}", myProcess->BasePriority );
            Console::WriteLine( "  priority class: {0}", myProcess->PriorityClass );
            Console::WriteLine( "  user processor time: {0}", myProcess->UserProcessorTime );
            Console::WriteLine( "  privileged processor time: {0}", myProcess->PrivilegedProcessorTime );
            Console::WriteLine( "  total processor time: {0}", myProcess->TotalProcessorTime );
            Console::WriteLine("  PagedSystemMemorySize64: {0}", myProcess->PagedSystemMemorySize64);
            Console::WriteLine("  PagedMemorySize64: {0}", 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: {0}", myProcess->ExitCode );
      
      // Display peak memory statistics for the process.
      Console::WriteLine( "Peak physical memory usage of the process: {0}", peakWorkingSet );
      Console::WriteLine( "Peak paged memory usage of the process: {0}", peakPagedMem );
      Console::WriteLine( "Peak virtual memory usage of the process: {0}", peakVirtualMem );
   }
   finally
   {
      if ( myProcess != nullptr )
      {
         myProcess->Close();
      }
   }

}
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}");
            }
        }
    }
}
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순위를 , , NormalHigh, AboveNormalBelowNormal또는 RealTime로 설정할 수 있습니다. 경과된 시간 또는 기타 향상에 따라 프로세서에 액세스하기 위해 프로세스를 다른 프로세스보다 앞서야 하는 경우 운영 체제에서 기본 우선 순위 수준을 변경할 수 있습니다. 또한 를 설정 PriorityBoostEnabled 하여 대기 상태에서 제거된 스레드의 우선 순위 수준을 일시적으로 높일 수 있습니다. 프로세스가 대기 상태로 돌아오면 우선 순위가 다시 설정됩니다.

BasePriority 속성을 사용하면 프로세스에 할당된 시작 우선 순위를 볼 수 있습니다. 그러나 읽기 전용이므로 속성을 사용하여 BasePriority 프로세스의 우선 순위를 설정할 수 없습니다. 우선 순위를 변경하려면 프로세스의 PriorityClass 전체 우선 순위 범주를 가져오거나 설정하는 속성을 사용합니다.

시스템 모니터를 사용하여 우선 순위 클래스를 볼 수 없습니다. 다음 표에서는 및 값 간의 BasePriority 관계를 보여 줍니다 PriorityClass .

BasePriority PriorityClass
4 Idle
8 Normal
13 High
24 RealTime

적용 대상

추가 정보