UtilProcessGetProcessCpuPercentUsageAsync(Int32) Method
Asynchronously gets the CPU percentage usage for the specified Process.
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 Task<float> GetProcessCpuPercentUsageAsync(
int pid
)
Public Shared Function GetProcessCpuPercentUsageAsync (
pid As Integer
) As Task(Of Single)
Dim pid As Integer
Dim returnValue As Task(Of Single)
returnValue = UtilProcess.GetProcessCpuPercentUsageAsync(pid)
public:
static Task<float>^ GetProcessCpuPercentUsageAsync(
int pid
)
static member GetProcessCpuPercentUsageAsync :
pid : int -> Task<float32>
No code example is currently available or this language may not be supported.
- pid Int32
-
Theprocess id.
TaskSingle
The resulting CPU percentage usage for the specified
Process.
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 = Await GetProcessCpuPercentUsageAsync(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.