상속: 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
파일: Program.cs 프로젝트: wgyswqs/esdk_Cgw
        /// <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
파일: Program.cs 프로젝트: wgyswqs/esdk_Cgw
        /// <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();
            }
        }