Click or drag to resize

ProcessPerfDataProvider Constructor

Initializes a new instance of the ProcessPerfDataProvider class.

Namespace:  Xcalibur.WMI.Processes
Assembly:  Xcalibur.WMI (in Xcalibur.WMI.dll) Version: 3.0.0.0 (3.0.1.0)
Syntax
public ProcessPerfDataProvider(
	ManagementScope ms,
	IProcessPerfDataConfig config,
	int id = -1
)

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
config
Type: Xcalibur.Models.ProcessesIProcessPerfDataConfig
The Process Performance Data Configuration.
id (Optional)
Type: SystemInt32
The Process Id.
Examples
C#
 1// Main
 2private static void Main()
 3{
 4    // Make a connection to the local machine
 5    const string computer = ".";
 6    var managementScope = new ManagementScope($@"\\{computer}\root\cimv2", new ConnectionOptions
 7    {
 8        Impersonation = ImpersonationLevel.Impersonate,
 9        Authentication = AuthenticationLevel.Connect
10    });
11    managementScope.Connect();
12
13    // Process data configuration
14    // We need to specify what we want to retrieve
15    var config = new ProcessDataConfig
16    {
17        ProcessId = true,
18        Name = true
19    };
20
21    // Process data information
22    var provider = new ProcessDataInfoProvider(managementScope, config);
23
24    // Fetch data
25    provider.Refresh();
26
27    // Print first 10 processes in order by Process Id
28    foreach (var info in provider.Results.OrderBy(x => x.ProcessId).Take(10))
29    {
30        Console.WriteLine($"{info.ProcessId}: \t{info.Name}");
31    }
32
33    // Read
34    Console.Read();
35}
36
37/* Results: 
38 * 
39 * 0:      System Idle Process
40 * 4:      System
41 * 404:    svchost.exe
42 * 476:    smss.exe
43 * 484:    fontdrvhost.exe
44 * 560:    fontdrvhost.exe
45 * 668:    svchost.exe
46 * 712:    csrss.exe
47 * 792:    wininit.exe
48 * 808:    csrss.exe
49 * 
50 */
See Also