Click or drag to resize

ProcessDataInfoPushProvider Constructor

Initializes a new instance of the ProcessDataInfoPushProvider class.

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

Parameters

ms
Type: System.ManagementManagementScope
The management scope.
config
Type: Xcalibur.Models.ProcessesIProcessDataConfig
The Process 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 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        KernelModeTime = true,
 20        UserModeTime = true
 21    };
 22
 23    // Process data information on a 1-second polling cycle for Process ID: 23100
 24    var provider = new ProcessDataInfoPushProvider(managementScope, config, 1000, 23100);
 25
 26    // Items Added
 27    provider.ItemsAdded += (item, e) =>
 28    {
 29        Console.WriteLine("Event: Item Added");
 30        Console.WriteLine($"{item.ProcessId}: \t{item.Name}");
 31        Console.WriteLine("");
 32    };
 33
 34    // Items Modified
 35    provider.ItemsModified += (item, e) =>
 36    {
 37        Console.WriteLine("Event: Item Modified");
 38        Console.WriteLine($"{item.ProcessId}: \t{item.Name}");
 39
 40        // We chose these values because we know they will constantly increase
 41        Console.WriteLine($"User Mode Time: \t{item.UserModeTime}");
 42        Console.WriteLine($"Kernel Mode Time: \t{item.KernelModeTime}");
 43        Console.WriteLine("");
 44    };
 45
 46    // Items Deleted
 47    provider.ItemsDeleted += (item, e) =>
 48    {
 49        Console.WriteLine("Event: Item Deleted");
 50        Console.WriteLine($"{item.ProcessId}: \t{item.Name}");
 51        Console.WriteLine("");
 52    };
 53
 54    // Read
 55    Console.Read();
 56}
 57
 58/* Results: 
 59 * 
 60 * Event: Item Added
 61 * 23100:  WindowsDashboard.exe
 62 * 
 63 * Event: Item Modified
 64 * 23100:  WindowsDashboard.exe
 65 * User Mode Time:         2235468750
 66 * Kernel Mode Time:       764843750
 67 * 
 68 * Event: Item Modified
 69 * 23100:  WindowsDashboard.exe
 70 * User Mode Time:         2238437500
 71 * Kernel Mode Time:       766093750
 72 * 
 73 * Event: Item Modified
 74 * 23100:  WindowsDashboard.exe
 75 * User Mode Time:         2239375000
 76 * Kernel Mode Time:       766093750
 77 * 
 78 * Event: Item Modified
 79 * 23100:  WindowsDashboard.exe
 80 * User Mode Time:         2242656250
 81 * Kernel Mode Time:       766406250
 82 * 
 83 * Event: Item Modified
 84 * 23100:  WindowsDashboard.exe
 85 * User Mode Time:         2243593750
 86 * Kernel Mode Time:       766718750
 87 * 
 88 * Event: Item Modified
 89 * 23100:  WindowsDashboard.exe
 90 * User Mode Time:         2244843750
 91 * Kernel Mode Time:       767500000
 92 * 
 93 * Event: Item Modified
 94 * 23100:  WindowsDashboard.exe
 95 * User Mode Time:         2247343750
 96 * Kernel Mode Time:       768281250
 97 * 
 98 * Event: Item Modified
 99 * 23100:  WindowsDashboard.exe
100 * User Mode Time:         2248906250
101 * Kernel Mode Time:       768906250
102 * 
103 * Event: Item Modified
104 * 23100:  WindowsDashboard.exe
105 * User Mode Time:         2250781250
106 * Kernel Mode Time:       769531250
107 * 
108 * Event: Item Modified
109 * 23100:  WindowsDashboard.exe
110 * User Mode Time:         2252812500
111 * Kernel Mode Time:       769843750
112 * 
113 * Event: Item Modified
114 * 23100:  WindowsDashboard.exe
115 * User Mode Time:         2255781250
116 * Kernel Mode Time:       770468750
117 * 
118 * Event: Item Modified
119 * 23100:  WindowsDashboard.exe
120 * User Mode Time:         2256718750
121 * Kernel Mode Time:       770937500
122 * 
123 */
See Also