void ServiceThreadHandler() { try { Debug.Print("ServiceThreadHandler"); needsShutdown.Reset(); NetInfo.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 ServiceThreadHandler() { try { Debug.Print("ServiceThreadHandler"); needsShutdown.Reset(); 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("Citrix Xen Guest Agent cannot find XenIface WMI interface"); } catch { }; int activehandle = WaitHandle.WaitAny(waitHandles); Debug.Print("Received event"); if (activehandle == 0) { try { EventLog.WriteEntry("Citrix Xen Guest Agent cannot find XenIface WMI interface"); } catch { }; starting = true; WmiCapableServiceThreadHandler(); starting = false; running = true; } } } catch (Exception e) { HandleException("Main Service Thread", e); } }
void WmiIncapableServiceThreadHandler(object nothing) { try { WmiBase.Reset(); if (WmiBase.Check()) { timer.Dispose(); Incapable.Set(); } } catch { timer.Dispose(); Incapable.Set(); } }
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(); } }