Process.PriorityClass Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri vagy beállítja a társított folyamat általános prioritási kategóriáját.
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
Tulajdonság értéke
A társított folyamat prioritási kategóriája, amelyből a BasePriority folyamat kiszámítása történik.
Kivételek
A folyamat prioritási információi nem állíthatók be vagy kérhetők le a társított folyamaterőforrásból.
-vagy-
A folyamatazonosító vagy a folyamatleíró értéke nulla. (A folyamat nem indult el.)
Egy távoli számítógépen futó folyamat tulajdonságához próbál hozzáférni PriorityClass . Ez a tulajdonság csak a helyi számítógépen futó folyamatokhoz érhető el.
A folyamat Id nem érhető el.
A prioritási osztály nem állítható be, mert nem használ érvényes értéket az ProcessPriorityClass enumerálásban meghatározottak szerint.
Példák
Az alábbi példa elindítja a Jegyzettömb egy példányát. A példa ezután lekéri és megjeleníti a társított folyamat különböző tulajdonságait. A példa észleli, hogy a folyamat mikor lép ki, és megjeleníti a folyamat kilépési kódját.
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
Megjegyzések
A tulajdonság által visszaadott érték a folyamat legutóbb frissített prioritását jelöli. A legfrissebb prioritás eléréséhez először meg kell hívnia Refresh() a metódust.
A folyamat prioritási osztálya a szál prioritási szintjeinek tartományát foglalja magában. A folyamat során futó különböző prioritású szálak a folyamat prioritási osztályához viszonyítva futnak. A Win32 négy prioritási osztályt használ osztályonként hét alap prioritási szinttel. Ezek a folyamatprioritási osztályok az ProcessPriorityClass enumerálásban vannak rögzítve, így a folyamat prioritását a következőre Idleállíthatja: , Normal, High, AboveNormal, BelowNormalvagy RealTime. Az eltelt idő vagy egyéb kiemelések alapján az alap prioritási szintet az operációs rendszer módosíthatja, amikor egy folyamatot mások előtt kell elvégezni a processzorhoz való hozzáféréshez. Emellett beállíthatja PriorityBoostEnabled , hogy ideiglenesen növelje a várakozási állapotból kivett szálak prioritási szintjét. A prioritás alaphelyzetbe áll, amikor a folyamat visszatér a várakozási állapotba.
A BasePriority tulajdonság lehetővé teszi a folyamathoz rendelt kezdő prioritás megtekintését. Mivel azonban írásvédett, a BasePriority tulajdonság nem használható a folyamat prioritásának beállítására. A prioritás módosításához használja a PriorityClass tulajdonságot, amely lekéri vagy beállítja a folyamat általános prioritási kategóriáját.
A prioritási osztály nem tekinthető meg a System Monitor használatával. Az alábbi táblázat az értékek és BasePriority az PriorityClass értékek közötti kapcsolatot mutatja be.
| BasePriority | PriorityClass |
|---|---|
| 4 | Idle |
| 8 | Normal |
| 13 | High |
| 24 | RealTime |