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 OnStop() { try { _instance.Dispose(); } catch (Exception ex) { File.WriteAllText("stop.err.log", ex.ToString()); } }
private void TryDispose() { try { _instance?.Dispose(); } catch { // Not much we can do here } }