void WmiCapableServiceThreadHandler() { try { wmisession = WmiBase.Singleton.GetXenStoreSession("Features"); wmisession.Log("Guest Agent Starting"); Refresher.Add(new PVInstallation(this)); wmisession.Log("About to run apps"); RunProcess("wmiadap", "/f", "refresh WMI ADAP"); RunProcess("diskperf", "-y", "enable disk perf counters"); wmisession.Log("About to run features"); new FeatureLicensed(this); new FeatureVSSLicensed(this); new FeatureDumpLog(this); new FeatureGC(this); new FeaturePing(this); new FeatureDomainJoin(this); new FeatureSetComputerName(this); new FeatureXSBatchCommand(this); new FeatureAutoUpdate(this); wmisession.Log("About to try snapshot"); if (FeatureSnapshot.IsSnapshotSupported()) { Refresher.Add(new FeatureSnapshot(this)); } else { wmisession.Log("Snapshot not supported on this platform"); FeatureSnapshot.removeSnapshot(wmisession); } new FeatureTerminalServicesReset(this); new FeatureTerminalServices(this); new FeatureStaticIpSetting(this); wmisession.Log("About to add refreshers"); Refresher.Add(new NetInfo(this)); Refresher.Add(new VolumeInfo()); Refresher.Add(new MemoryInfo()); wmisession.Log("About to add handlers "); clipboardhandler = new ClipboardManager(this); Disposer.Add(clipboardhandler); clipboardhandler.Run(); Disposer.Add(WmiBase.Singleton.ListenForEvent("CitrixXenStoreUnsuspendedEvent", new EventArrivedEventHandler(handleUnsuspended))); Refresher.RefreshAll(true); wmisession.Log("running "); Refresher.Run(this); } catch (Exception e) { HandleException("Service handler", e); } }
void handleUnsuspended(object nothing, EventArrivedEventArgs args) { try { Refresher.RefreshAll(true); } catch (Exception e) { HandleException("Resume from suspend", e); } }
void ServiceThreadShutdown() { try { try { Refresher.Dispose(); Disposer.Dispose(); } catch (Exception ex) { wmisession.Log("Errors disposing of threads: " + ex.ToString()); throw; } wmisession.Log("Guest Agent Stopped"); try { wmisession.Dispose(); } catch { } } catch {} finally { WmiBase.Reset(); } }