Пример #1
0
 /// <summary>
 /// Dispose and stop
 /// </summary>
 public void Dispose()
 {
     AppDomain.CurrentDomain.ProcessExit -= AppDomainExit;
     Console.CancelKeyPress -= Console_CancelKeyPress;
     windowsService?.Stop();
     windowsService = null;
     stop?.Invoke();
     stop = null;
 }
Пример #2
0
 private void RunWindowsService(string[] args)
 {
     if (Console.IsInputRedirected)
     {
         // create and start using Windows service APIs
         windowsService = new IPBanWindowsServiceRunner(this, args);
     }
     else
     {
         RunConsoleService(args);
     }
 }
Пример #3
0
 private async Task RunWindowsService(string[] args)
 {
     if (Console.IsInputRedirected)
     {
         // create and start using Windows service APIs
         windowsService = new IPBanWindowsServiceRunner(this, args);
         await windowsService.Run();
     }
     else
     {
         await RunConsoleService(args);
     }
 }
Пример #4
0
 private async Task RunWindowsService(string[] args)
 {
     // if we have no console input and we are not in IIS, run as windows service
     if (Console.IsInputRedirected && !OSUtility.IsRunningInProcessIIS())
     {
         // create and start using Windows service APIs
         windowsService = new IPBanWindowsServiceRunner(this, args);
         await windowsService.Run();
     }
     else
     {
         await RunConsoleService(args);
     }
 }
Пример #5
0
 private async Task RunWindowsService(string[] args)
 {
     // if we have no console input and we are not in IIS and not running an installer, run as windows service
     if (Console.IsInputRedirected && !OSUtility.IsRunningInProcessIIS() &&
         !args.Any(a => a.StartsWith("-install", StringComparison.OrdinalIgnoreCase)))
     {
         // create and start using Windows service APIs
         windowsService = new IPBanWindowsServiceRunner(this, args);
         await windowsService.Run();
     }
     else
     {
         await RunConsoleService(args);
     }
 }
Пример #6
0
        /// <summary>
        /// Dispose and stop
        /// </summary>
        public void Dispose()
        {
            IPBanWindowsServiceRunner runner = windowsService;

            windowsService = null;
            if (runner != null)
            {
                runner.Stop();
            }
            Action stopper = stop;

            stop = null;
            if (stopper != null)
            {
                stopper.Invoke();
            }
        }