Example #1
0
 static void Main(string[] args)
 {
     try
     {
         var displayName = ConfigurationManager.AppSettings["ServiceDisplayName"].Trim();
         var taskService = new Task4WinService();
         Log.Info("try run the {0}.", displayName);
         taskService.Start();
         Log.Info("{0} is runing.", displayName);
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         Log.Fatal(ex, "启动服务时发生异常");
         throw;
     }
 }
Example #2
0
 /// <summary>
 /// 启动服务
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     try
     {
         if (_taskService == null)
         {
             _taskService = new Task4WinService();
         }
         log.Info("try run the {0}.", _displayName);
         _taskService.Start();
         log.Info("{0} is runing.", _displayName);
     }
     catch (Exception ex)
     {
         log.Fatal(ex, "启动服务时发生异常");
         throw;
     }
 }