public void Run() { Console.WriteLine($"Starting {Assembly.GetEntryAssembly().FullName} in console, press CTRL+C to exit . . ."); Console.WriteLine(); Console.CancelKeyPress += ConsoleOnCancelKeyPress; _instance.Start(); _cancelEvent.Wait(); Console.WriteLine("CTRL+C pressed, stopping..."); _instance.Dispose(); }
protected override void OnStart(string[] args) { try { _instance.Start(); base.OnStart(args); } catch (Exception ex) { Log.StartupError(ex.ToString()); TryDispose(); Environment.Exit(-1); } }