Instance() static public method

单实例
static public Instance ( ) : MonitorManageService
return MonitorManageService
Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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();
            }
        }