public static void Main(string [] args) { // To configure this application to run as a service, run these commands as an admin: // sc create SERVICE_NAME type= own start= auto binPath= "FULL_PATH_TO_EXE\IpcServer.exe /service" // sc failure SERVICE_NAME reset= 86400 actions= restart/60000/restart/60000/restart/60000 // sc start SERVICE_NAME // // Other useful commands // sc stop SERVICE_NAME // sc delete SERVICE_NAME if (args.Length > 0 && args[0] == "/service") { // Run as a service application ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new DemoService() }; ServiceBase.Run(ServicesToRun); } else { // Run as a Windows console application DemoIpcServer m_server = new DemoIpcServer(); m_server.Start(); // Since all the requests are issued asynchronously, the constructors are likely to return // before all the requests are complete. The call below stops the application from terminating // until we see all the responses displayed. Thread.Sleep(1000); Console.WriteLine("\nPress return to shutdown server"); Console.ReadLine(); m_server.Stop(); Console.WriteLine("\nComplete! Press return to exit program"); Console.ReadLine(); } }
static void Main() { #if DEBUG try { ServiceStartup.Main(); Console.WriteLine("Press <CTRL>+C to stop."); Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { Console.WriteLine("ERROR: {0}: {1}", ex.GetType().Name, ex.Message); throw; } finally { ServiceStartup.Stop(); } #else var appHost = ServiceStartup.GetAppHostListner(); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new WinService(appHost, ServiceStartup.ListeningOn) }; ServiceBase.Run(ServicesToRun); #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { if (System.Environment.UserInteractive) { ILog m_log = LogManager.GetLogger("Service Install"); string parameter = string.Concat(args); switch (parameter) { case "--install": ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); break; case "--uninstall": ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); break; case "--start": Start(args); break; case "--stop": Stop(); break; } } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new pGinaServiceHost() }; ServiceBase.Run(ServicesToRun); } }
/// <summary> /// Главная точка входа для приложения. /// </summary> static void Main() { var servicesToRun = new ServiceBase[] { new HelperService() }; ServiceBase.Run(servicesToRun); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new EvLogMailService() }; ServiceBase.Run(ServicesToRun); }
public UserController() { var xbuilder = new ContainerBuilder(); xbuilder.RegisterType<EFClient<User>>().As<IDao<User>>(); xbuilder.RegisterType<UserService>(); using (var container = xbuilder.Build()) { _service = container.Resolve<UserService>(); } }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ComputerMonitorService() }; ServiceBase.Run(ServicesToRun); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new MediaDatabaseService() }; ServiceBase.Run(ServicesToRun); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new DDnsSharpService() }; ServiceBase.Run(ServicesToRun); }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new AutoImport() }; ServiceBase.Run(ServicesToRun); }
private static void Main() { #if !debug Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FrmMain()); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new MainService() }; ServiceBase.Run(ServicesToRun); #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { #region test Section //Service1.OnDebug(); //Console.ReadKey(); //return; #endregion ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); }
internal static void Main() { System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; if (Medo.Application.Args.Current.ContainsKey("Interactive")) { Tray.Show(); ServiceThread.Start(); Tray.SetStatusToRunningInteractive(); Application.Run(); ServiceThread.Stop(); Tray.Hide(); Environment.Exit(0); } else if (Medo.Application.Args.Current.ContainsKey("Install")) { ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); System.Environment.Exit(0); } else if (Medo.Application.Args.Current.ContainsKey("Uninstall")) { try { ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); System.Environment.Exit(0); } catch (System.Configuration.Install.InstallException) { //no service with that name System.Environment.Exit(-1); } } else { if (Environment.UserInteractive) { Tray.Show(); ServiceStatusThread.Start(); Application.Run(); ServiceStatusThread.Stop(); Tray.Hide(); Environment.Exit(0); } else { ServiceBase.Run(new ServiceBase[] { AppService.Instance }); } } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { try { TimeDateTraceListener.Initialize("InstallAgent"); if (args.Length == 0) // run as service { // rebootOption is populated in the constructor ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new InstallAgent() }; ServiceBase.Run(ServicesToRun); } else if (args.Length == 1) // run from command line { InstallAgent.RebootType rebootOpt; try { rebootOpt = (InstallAgent.RebootType)Enum.Parse( typeof(InstallAgent.RebootType), args[0], true ); } catch { Usage(); return; } InstallAgent ias = new InstallAgent(rebootOpt); ias.InstallThreadHandler(); } else { Usage(); } } catch (Exception e) { Trace.WriteLine(e.ToString()); throw; } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { string[] args = Environment.GetCommandLineArgs(); // --install site host // --uninstall if (args[1].Equals("-i")) { string path = Environment.CurrentDirectory + "\\" + ServiceMain.EXE_NAME; string site = args[2]; string host = args[3]; StringBuilder exeArgs = new StringBuilder("create \"" + ServiceMain.SERVICE_NAME + " " + site + " " + host + "\" "); exeArgs.Append("binPath=\"" + path + "\" "); exeArgs.Append("DisplayName=\"" + ServiceMain.DISPLAY_NAME + "\" "); exeArgs.Append("start=auto"); string outStr = ExecCommand.Execute("sc", exeArgs.ToString()); System.Console.WriteLine(outStr); } // --uninstall else if (args[1].Equals("-u")) { StringBuilder exeArgs = new StringBuilder("delete \"" + ServiceMain.SERVICE_NAME + "\""); string outStr = ExecCommand.Execute("sc", exeArgs.ToString()); System.Console.WriteLine(outStr); } if (args[1].Equals("-d")) //Debug { string path = Environment.CurrentDirectory + "\\" + ServiceMain.EXE_NAME; ServiceMain app = new ServiceMain(); app.debugOnStart(); System.Console.ReadLine(); } else if (args.Length == 3) { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ServiceMain() }; ServiceBase.Run(ServicesToRun); } }
static void Main() { log4net.Config.XmlConfigurator.Configure(); Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger("Startup").Debug("This logging call loads the configuration"); ProcessStarter service = new ProcessStarter { CanShutdown = true }; #if DEBUG Win32.AllocConsole(); service.Initialise(); #else ServiceBase.Run(new ServiceBase[] { service }); #endif }
static void Main(string[] args) { var settings = new SelfHostSettings(CommandLineSettings.Parse(args)); var service = new KlondikeService(settings); if (settings.Interactive || Environment.UserInteractive) { Console.WriteLine("Running interactively"); service.RunInteractivley(); } else { Console.WriteLine("Running as service"); ServiceBase.Run(service); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new TalentManagerEmailService() }; if (Environment.UserInteractive) { RunInteractive(ServicesToRun); } else { ServiceBase.Run(ServicesToRun); } }
static void Main(string[] args) { MyNewService service = new MyNewService(); if (Environment.UserInteractive) { service.OnStart(args); Console.WriteLine("Install as service: installutil MyNewService.exe"); Console.WriteLine("Press any key to stop program"); Console.Read(); service.OnStop(); } else { ServiceBase.Run(service); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { #if DEBUG var container = ServiceStart.SimpleInjectorInitializer.Initialize(); PresenceServiceInitializer.configure(container); while (true) { } #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new PresenceService() }; ServiceBase.Run(ServicesToRun); #endif }
static void Main(string[] args) { if (args.Contains("-p")) { using (FileProcessor mgr = new FileProcessor(args)) mgr.ShutdownEvent.WaitOne(); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new StandardService(args) }; ServiceBase.Run(ServicesToRun); } }
static void Main() { #if(!DEBUG) ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new MyService() }; ServiceBase.Run(ServicesToRun); #else MyService myServ = new MyService(); myServ.Process(); // here Process is my Service function // that will run when my service onstart is call // you need to call your own method or function name here instead of Process(); #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new PrevensomewareScheduler() }; if (!Environment.UserInteractive) { ServiceBase.Run(ServicesToRun); } else { string[] args = { "10", ".html:.wwhtml", @"C:\Users\thewh\Desktop\Schule\7_10\Meine Webseite" }; new PrevensomewareScheduler().DebugService(args); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { if (Environment.UserInteractive) { TimeManagement.Instance.EnableFileWatch(); Thread.Sleep(100000); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new TimeSheetManagement() }; ServiceBase.Run(ServicesToRun); } }
public void TestBuildDeluxeService() { #region Service and Worker Team var TestTeamLeader = new TeamLeader(TestLeaderSalary); var TestWorker1 = new Worker(TestWorkerSalary); var TestWorker2 = new Worker(TestWorkerSalary); var TestWorker3 = new Worker(TestWorkerSalary); #endregion #region ServiceBase TestDeluxeService = TestService.BuildService("Deluxe") as ServiceBase; TestTeamLeader.AddWorker(TestWorker1); TestTeamLeader.AddWorker(TestWorker2); TestTeamLeader.AddWorker(TestWorker3); TestDeluxeService.Team = TestTeamLeader; #endregion #region Asserts: Control vars var TestPoison = TestDeluxeService.Poison; var TestAnimal = TestDeluxeService.Animal; var TestBleach = TestDeluxeService.Assets.Where(x => x.GetType() == typeof(Bleach)).Single(); var TestProtectionSuites = TestDeluxeService.Assets.Where(x => x.GetType() == typeof(ProtectionSuite)).ToList(); var TestSimpleMasks = TestDeluxeService.Assets.Where(x => x.GetType() == typeof(SimpleMask)).ToList(); var TestFinalPrice = TestTeamLeader.Price + TestPoison.Price + TestBleach.Price + TestProtectionSuites.Sum(x => x.Price) + TestSimpleMasks.Sum(x => x.Price); #endregion #region Asserts Assert.AreEqual(typeof(Rat), TestAnimal.GetType(), "Different Animal types!"); Assert.AreEqual(typeof(Arsenic), TestPoison.GetType(), "Different Poison types!"); Assert.AreEqual(TestPoison, TestDeluxeService.Assets.Where(x => x.Equals(TestDeluxeService.Poison)).SingleOrDefault(), "Different Poison instances!"); Assert.AreEqual(3, TestProtectionSuites.Count(), "Not enough ProtectionSuites found!"); Assert.AreEqual(3, TestSimpleMasks.Count(), "Not enough SimpleMasks found!"); Assert.AreEqual(1000, TestProtectionSuites[0].Price, "Different ProtectionSuite prices!"); Assert.AreEqual(1000, TestProtectionSuites[1].Price, "Different ProtectionSuite prices!"); Assert.AreEqual(1000, TestProtectionSuites[2].Price, "Different ProtectionSuite prices!"); Assert.AreEqual(80, TestSimpleMasks[0].Price, "Different SimpleMask prices!"); Assert.AreEqual(80, TestSimpleMasks[1].Price, "Different SimpleMask prices!"); Assert.AreEqual(80, TestSimpleMasks[2].Price, "Different SimpleMask prices!"); Assert.AreEqual(500, TestBleach.Price, "Different Bleach prices!"); Assert.AreEqual(TestFinalPrice, TestDeluxeService.Price, "Service price is different!"); #endregion }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { if (Environment.UserInteractive) { var service = new CustomJobService(); service.Debug(args); } else { var servicesToRun = new ServiceBase[] { new CustomJobService() }; ServiceBase.Run(servicesToRun); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { #if RunAsApp // Run as Windows Application. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DebugHost()); #else // Run as Windows Service. ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ServiceHost() }; ServiceBase.Run(ServicesToRun); #endif }
static void Main() { // Call the service in DEBUG mode so we don't need to run the install steps. #if DEBUG log.Info("Blaise Case Handler service starting in DEBUG mode."); BlaiseCaseHandler bchService = new BlaiseCaseHandler(); bchService.OnDebug(); #else log.Info("Blaise Case Handler service starting in RELEASE mode."); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new BlaiseCaseHandler() }; ServiceBase.Run(ServicesToRun); #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { var service = new Service1(); #if DEBUG service.DebugMode(); Thread.Sleep(Timeout.Infinite); #else log4net.Config.XmlConfigurator.Configure(); ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { service }; ServiceBase.Run(ServicesToRun); #endif }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { #if DEBUG //While debugging this section is used. SyncOmsService myService = new SyncOmsService(); myService.onDebug(); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); #else //In Release this section is used. This is the "normal" way. ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SyncOmsService() }; ServiceBase.Run(ServicesToRun); #endif }
static void Main(string[] args) { try { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SenderFeed2SCUService() }; ServiceBase.Run(ServicesToRun); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); Console.ReadKey(); } }
/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { #if DEBUG var service = new Service(); service.StartService(); Console.ReadKey(); service.Stop(); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service() }; ServiceBase.Run(ServicesToRun); #endif }
static void Main() { Detect_info test_ins = new Detect_info();//使用之前导入的参数判断是以windows服务启动还是启动安装程序;*/*/在Start.cs内的类 if (test_ins.Detect() == "installed") {//这一段是判断是否输入过用户密码,有则会成为服务的形式运行,否则执行else,将会变为控制台程序获取输入*/ ServiceBase[] ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); }//到这里为服务本体,在OnStart方法启动---------------------------------------------------------------*/ else { Ride_info test_ins2 = new Ride_info();//Start.cs内的类 } }
/// <summary> /// 應用程式的主要進入點。 /// </summary> static void Main() { if (Environment.UserInteractive) { DataImportService svc = new DataImportService(); svc.TestStartupAndStop(null); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new DataImportService() }; ServiceBase.Run(ServicesToRun); } }
private void GetDinamicData() { projectsService = new ServiceBase(this); if(GlobalParams.Instance.HasInternetConnection) { projectsService.onServiceComplete += OnGetDataComplete; projectsService.GetProjectsInfoByUserID( GlobalParams.Instance.connectionParameters.UserID ); } else if(!string.IsNullOrEmpty( LocalStorage.AppProjectsInfo ) ) { projectsService.ParseInfoToProjectDescriptor( LocalStorage.AppProjectsInfo ); projects = projectsService.projects; } else Debug.Log("You don't have connection internet"); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { if (Environment.UserInteractive) { Service1 service1 = new Service1(); service1.TestStartupAndStop(args); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); } }
static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new k163805_Q3() }; //ServiceBase.Run(ServicesToRun); if (Environment.UserInteractive) { RunInteractive(ServicesToRun); } else { ServiceBase.Run(ServicesToRun); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { //#if !DEBUG ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new TvCableConciliacionService() }; ServiceBase.Run(ServicesToRun); //#else //TvCableConciliacionService obj = new TvCableConciliacionService(); //obj.OnStart(); // TvCableConciliacionService inicio = new TvCableConciliacionService(); // inicio.DoWork(); //#endif }
/// <summary> /// Punto di ingresso principale dell'applicazione. /// </summary> static void Main() { if (Environment.UserInteractive)//&& System.Diagnostics.Debugger.IsAttached) { Scheduler telegramPolling = new Scheduler(); telegramPolling.Start(); Console.WriteLine("Premi un tasto per continuare..."); Console.ReadKey(); telegramPolling.Stop(); } else { ServiceBase.Run(new Scheduler()); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { #if DEBUG using (var s = new Service1()) { s.OnDebug(); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); #endif }
/// <summary> /// The main entry point for the application. /// </summary> public static void Main(string[] args) { if (Environment.UserInteractive) { var service = new SuncatService(); service.OnDebug(args); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SuncatService() }; ServiceBase.Run(ServicesToRun); } }
static void Main(string[] args) { ServiceController service = new ServiceController("WCFServiceMgr"); if (args.Length == 0) { ServiceBase[] serviceRun; serviceRun = new ServiceBase[] { new WCFServiceMgr() }; ServiceBase.Run(serviceRun); } else if (args[0].ToLower() == "/i" || args[0].ToLower() == "-i") { if (!IsServiceExisted("WCFServiceMgr")) { try { string[] cmdLine = { }; string exeLocalhost = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller install = new TransactedInstaller(); AssemblyInstaller assmeInstall = new AssemblyInstaller(exeLocalhost, cmdLine); install.Installers.Add(assmeInstall); install.Install(new System.Collections.Hashtable()); TimeSpan timeout = TimeSpan.FromMilliseconds(1000 * 10); service.Start(args); service.WaitForStatus(ServiceControllerStatus.Running, timeout); } catch (Exception ex) { throw ex; } } } else if (args[0].ToLower() == "/u" || args[0].ToLower() == "-u") { string[] cmdLine = { }; string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller install = new TransactedInstaller(); AssemblyInstaller assmInstall = new AssemblyInstaller(exeFileName, cmdLine); install.Installers.Add(assmInstall); install.Uninstall(null); service.Start(args); service.WaitForStatus(ServiceControllerStatus.Stopped); } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { //var appHost = new StarterTemplateAppListenerHost(); //Allow you to debug your Windows Service while you're deleloping it. #if DEBUG Console.WriteLine("Running WinServiceAppHost in Console mode"); try { //appHost.Init(); //appHost.Start(ListeningOn); //Console.WriteLine("Press <CTRL>+C to stop."); //Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { Console.WriteLine("ERROR: {0}: {1}", ex.GetType().Name, ex.Message); throw; } finally { //appHost.Stop(); } Console.WriteLine("WinServiceAppHost has finished"); #else //When in RELEASE mode it will run as a Windows Service with the code below ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new WinService(appHost, ListeningOn) }; ServiceBase.Run(ServicesToRun); #endif }
public ServiceBase(ServiceBase service) { Device = service.Device; Information = service.Information; }
public static void Run(ServiceBase[] services) { }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { if (System.Environment.UserInteractive) { // Initalize logging and grab a logger pGina.Shared.Logging.Logging.Init(); ILog m_log = LogManager.GetLogger("Service Install"); try { string parameter = string.Concat(args); switch (parameter) { case "--install": m_log.DebugFormat("Installing service..."); ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location }); break; case "--uninstall": m_log.DebugFormat("Uninstalling service..."); ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); break; case "--start": m_log.Debug("Starting service..."); Start(args); break; case "--stop": m_log.Debug("Stopping service..."); Stop(); break; } } catch (Exception e) { m_log.ErrorFormat("Uncaught exception in UserInteractive mode: {0}", e); Environment.Exit(1); } } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new pGinaServiceHost() }; ServiceBase.Run(ServicesToRun); } }
// The main service loop private void MainLoop (ServiceBase [] services) { try { ServiceBase service; if (services == null || services.Length == 0){ error (logname, "No services were registered by this service"); return; } // Start up the service. service = null; if (name != null){ foreach (ServiceBase svc in services){ if (svc.ServiceName == name){ service = svc; break; } } } else { service = services [0]; } if (service.ExitCode != 0) { //likely due to a previous execution, so we need to reset it to default service.ExitCode = 0; } call (service, "OnStart", args); info (logname, "Service {0} started", service.ServiceName); UnixSignal intr = new UnixSignal (Signum.SIGINT); UnixSignal term = new UnixSignal (Signum.SIGTERM); UnixSignal usr1 = new UnixSignal (Signum.SIGUSR1); UnixSignal usr2 = new UnixSignal (Signum.SIGUSR2); UnixSignal[] sigs = new UnixSignal[]{ intr, term, usr1, usr2 }; for (bool running = true; running; ){ int idx = UnixSignal.WaitAny (sigs); if (idx < 0 || idx >= sigs.Length) continue; if ((intr.IsSet || term.IsSet) && service.CanStop) { intr.Reset (); term.Reset (); info (logname, "Stopping service {0}", service.ServiceName); call (service, "OnStop", null); if (service.ExitCode != 0) error (logname, "Service stopped with a non-zero ExitCode: {0}", service.ExitCode); running = false; } else if (usr1.IsSet && service.CanPauseAndContinue) { usr1.Reset (); info (logname, "Pausing service {0}", service.ServiceName); call (service, "OnPause", null); } else if (usr2.IsSet && service.CanPauseAndContinue) { usr2.Reset (); info (logname, "Continuing service {0}", service.ServiceName); call (service, "OnContinue", null); } } } finally { // Clean up foreach (ServiceBase svc in services){ svc.Dispose (); } } }
public static void Run(ServiceBase service) { }