static public Instance ( ) : |
||
return |
/// <summary> /// 开启服务函数 /// </summary> static void StartService() { MonitorManageService inist = MonitorManageService.Instance(); ServiceHost host = new ServiceHost(inist); inist.SetHost(host); host.Opened += delegate { NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log); Thread dbConnectionThread = new Thread(new ThreadStart(LoadMonitorTimer_Elapsed)); dbConnectionThread.Start(); logEx.Info("Enter: Start CgwMonitorManage.Service"); }; host.Open(); ServiceBase.Run(inist); }
/// <summary> /// 线程加载监控平台 /// </summary> private static void LoadMonitorTimer_Elapsed() { NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log); System.Threading.Thread.Sleep(CgwConst.Thread_Sleep_Time); SmcErr smcErr = new SmcErr(); try { smcErr = MonitorManageService.Instance().Load(); if (false == smcErr.IsSuccess()) { logEx.Error("MonitorManageService Start failed! Errno :{0}", smcErr.ErrNo); NLog.LogManager.Flush(); System.Diagnostics.Process.GetCurrentProcess().Kill(); } } catch (Exception ex) { logEx.Fatal(ex, "MonitorManageService LoadMonitor Failed!"); NLog.LogManager.Flush(); } }