Example #1
0
 protected override void OnStop()
 {
     // TODO: Add code here to perform any tear-down necessary to stop your service.
     Logger.LogInfo("OnStop...");
     try { ServiceLauncher.Stop(); }
     catch (Exception ex)
     {
         UnhandledException(ex);
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            Logger.LogInfo("Main...");
            ServiceBase[] ServicesToRun;
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(WorkerThreadHandler);
            if (System.AppDomain.CurrentDomain.BaseDirectory != Directory.GetCurrentDirectory(  ) + @"\")
            {
                ServicesToRun = new ServiceBase[] { new MyService() };

                Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
                Process.GetCurrentProcess().StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                ServiceLauncher.Run(args);
            }
        }