void ServiceThreadHandler() { try { Debug.Print("ServiceThreadHandler"); needsShutdown.Reset(); VifInfo.StoreChangedNetworkSettings(); WmiBase.Reset(); Debug.Print("WMI Check"); if (WmiBase.Check()) { starting = true; WmiCapableServiceThreadHandler(); starting = false; running = true; } else { running = false; WaitHandle[] waitHandles = new WaitHandle[] { (new WmiIncapableThread()).Incapable, needsShutdown }; Debug.Print("Waiting for WMI capability to begin"); try { EventLog.WriteEntry(Branding.Instance.getString("BRANDING_errNoWMI")); } catch { }; int activehandle = WaitHandle.WaitAny(waitHandles); Debug.Print("Received event"); if (activehandle == 0) { try { EventLog.WriteEntry(Branding.Instance.getString("BRANDING_errNoWMI")); } catch { }; starting = true; WmiCapableServiceThreadHandler(); starting = false; running = true; } } } catch (Exception e) { HandleException("Main Service Thread", e); } }
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 VifFeatureStaticIpSetting(this); new VfFeatureStaticIpSetting(this); wmisession.Log("About to add refreshers"); VifInfo vifRefresher = new VifInfo(this); Refresher.Add(vifRefresher); Disposer.Add(vifRefresher); VfInfo vfRefresher = new VfInfo(this); Refresher.Add(vfRefresher); Disposer.Add(vfRefresher); Refresher.Add(new VolumeInfo()); Refresher.Add(new MemoryInfo()); Refresher.Add(new XenAppSessionInfo()); 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); } }