UtilProcessGetProcessCpuPercentUsage(Int32) Method
Gets the CPU percentage usage for the process with the specified process id. (PID).
Namespace: DevCase.Core.Diagnostics.ProcessesAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public static float GetProcessCpuPercentUsage(
int pid
)
Public Shared Function GetProcessCpuPercentUsage (
pid As Integer
) As Single
Dim pid As Integer
Dim returnValue As Single
returnValue = UtilProcess.GetProcessCpuPercentUsage(pid)
public:
static float GetProcessCpuPercentUsage(
int pid
)
static member GetProcessCpuPercentUsage :
pid : int -> float32
No code example is currently available or this language may not be supported.
- pid Int32
-
The process id.
Single
The resulting CPU percentage usage for the process with the specified process id. (PID).
Before calling this method, performance counters must be enabled in the 'app.config' file. See the next example:
<configuration>
...
<system.net>
<settings>
<performanceCounters enabled="true"/>
</settings>
</system.net>
...
</configuration>
This is a code example.
No code example is currently available or this language may not be supported.
Dim pr As Process = Process.GetCurrentProcess()
Dim cpuPercent As Single = GetProcessCpuPercentUsage(pr.Id)
Dim str As String = String.Format("Process Name: {0}; CPU Usage: {1:F2}%", pr.ProcessName, cpuPercent)
Console.WriteLine(str)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.