Click or drag to resize

ProcessDataPerfInfoPushProvider Constructor

Initializes a new instance of the ProcessDataPerfInfoPushProvider class.

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

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
config
Type: Xcalibur.Models.ProcessesIProcessPerfDataConfig
The Process Performance Data Configuration.
interval
Type: SystemInt32
The polling interval in milliseconds.
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 performance data configuration
 14    // We need to specify what we want to retrieve
 15    var config = new ProcessPerfDataConfig
 16    {
 17        IDProcess = true,
 18        Name = true,
 19        WorkingSet = true,
 20        WorkingSetPrivate = true,
 21        Timestamp_Sys100NS = true
 22    };
 23
 24    // Process performance data information on a 1-second polling cycle for Process ID: 19248
 25    var provider = new ProcessDataPerfInfoPushProvider(managementScope, config, 1000, 19248);
 26
 27    // Items Added
 28    provider.ItemsAdded += (item, e) =>
 29    {
 30        Console.WriteLine("Event: Item Added");
 31        Console.WriteLine($"{item.IDProcess}: \t{item.Name}");
 32        Console.WriteLine("");
 33    };
 34
 35    // Items Modified
 36    provider.ItemsModified += (item, e) =>
 37    {
 38        Console.WriteLine("Event: Item Modified");
 39        Console.WriteLine($"{item.IDProcess}: \t{item.Name}");
 40
 41        // We chose these values because we know they will constantly increase
 42        Console.WriteLine($"Working Set: \t\t{item.WorkingSet}");
 43        Console.WriteLine($"Private Working Set: \t{item.WorkingSetPrivate}");
 44        Console.WriteLine($"Timestamp: \t\t{item.TimestampSys100Ns}");
 45        Console.WriteLine("");
 46    };
 47
 48    // Items Deleted
 49    provider.ItemsDeleted += (item, e) =>
 50    {
 51        Console.WriteLine("Event: Item Deleted");
 52        Console.WriteLine($"{item.IDProcess}: \t{item.Name}");
 53        Console.WriteLine("");
 54    };
 55
 56    // Read
 57    Console.Read();
 58}
 59
 60/* Results: 
 61 * 
 62 *  Event: Item Added
 63 *  19248:  WindowsDashboard
 64 *  
 65 *  Event: Item Modified
 66 *  19248:  WindowsDashboard
 67 *  Working Set:            114995200
 68 *  Private Working Set:    49004544
 69 *  Timestamp:              131654592956557516
 70 *  
 71 *  Event: Item Modified
 72 *  19248:  WindowsDashboard
 73 *  Working Set:            115326976
 74 *  Private Working Set:    49336320
 75 *  Timestamp:              131654592978271674
 76 *  
 77 *  Event: Item Modified
 78 *  19248:  WindowsDashboard
 79 *  Working Set:            115331072
 80 *  Private Working Set:    49340416
 81 *  Timestamp:              131654593000080330
 82 *  
 83 *  Event: Item Modified
 84 *  19248:  WindowsDashboard
 85 *  Working Set:            115331072
 86 *  Private Working Set:    49373184
 87 *  Timestamp:              131654593022029765
 88 *  
 89 *  Event: Item Modified
 90 *  19248:  WindowsDashboard
 91 *  Working Set:            115331072
 92 *  Private Working Set:    49373184
 93 *  Timestamp:              131654593044073874
 94 *  
 95 *  Event: Item Modified
 96 *  19248:  WindowsDashboard
 97 *  Working Set:            114966528
 98 *  Private Working Set:    49008640
 99 *  Timestamp:              131654593065870185
100 *  
101 *  Event: Item Modified
102 *  19248:  WindowsDashboard
103 *  Working Set:            114974720
104 *  Private Working Set:    49016832
105 *  Timestamp:              131654593087916491
106 *  
107 *  Event: Item Modified
108 *  19248:  WindowsDashboard
109 *  Working Set:            115290112
110 *  Private Working Set:    49332224
111 *  Timestamp:              131654593109661946
112 * 
113 */
See Also