/// <summary> /// Dispose and stop /// </summary> public void Dispose() { AppDomain.CurrentDomain.ProcessExit -= AppDomainExit; Console.CancelKeyPress -= Console_CancelKeyPress; windowsService?.Stop(); windowsService = null; stop?.Invoke(); stop = null; }
private void RunWindowsService(string[] args) { if (Console.IsInputRedirected) { // create and start using Windows service APIs windowsService = new IPBanWindowsServiceRunner(this, args); } else { RunConsoleService(args); } }
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); } }
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); } }
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); } }
/// <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(); } }