Inheritance: System.ServiceProcess.ServiceBase, IMonitorManageService, IServiceBehavior
示例#1
0
 /// <summary>
 /// 单实例
 /// </summary>
 /// <returns></returns>
 static public MonitorManageService Instance()
 {
     if (monitorManageService == null)
     {
         lock (instanceLocker)
         {
             monitorManageService = new MonitorManageService();
         }
     }
     return(monitorManageService);
 }
示例#2
0
 /// <summary>
 /// 单实例
 /// </summary>
 /// <returns></returns>
 static public MonitorManageService Instance()
 {
     if (monitorManageService == null)
     {
         lock (instanceLocker)
         {
             monitorManageService = new MonitorManageService();
         }
     }
     return monitorManageService;
 }
示例#3
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);
        }
示例#4
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();
            }
        }