Executes a WMI query on a collection of remote servers.
Inheritance Hierarchy
CleanCode.Threading ThreadWorker
CleanCode.Net WMIWorker
Namespace: CleanCode.Net
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax
public class WMIWorker : ThreadWorker
Remarks
WMIWorker is an implementation of the abstract ThreadWorker class, which performs work in a background thread allowing your foreground GUI to continue interacting with a user. Results are returned via a callback routine that is invoked when you poll for completed items.
See the remarks for ThreadManager for a comprehensive discussion of how to wire up and use ThreadWorkers.
Since CleanCode 0.9.07.
Examples
private void LoadServer1Fields( WMIHelper wmiHelper, string status, DateTime refTime) { if (status.Equals("ok")) { wmiHelper.SetSection("Win32_OperatingSystem"); serverOSName = wmiHelper.GetServerInfo("Caption"); . . . } } wmiWorker = new WMIWorker(); wmiWorker.AddRequest( "server1", new WMIHelper(server, domain, user, pwd), new WMIWorker.WMIUpdater(LoadServer1Fields)); wmiWorker.AddRequest( "server2", new WMIHelper(server, domain, user, pwd), new WMIWorker.WMIUpdater(LoadServer2Fields)); wmiWorker.AddRequest( "client", new WMIHelper(), new WMIWorker.WMIUpdater(LoadClientFields)); threadManager.Add(wmiWorker); threadManager.Run(); // start threads // Poll this periodically... wmiWorker.updateResults();
See Also