public static void Main(string[] args) { // init and start var config = new HomeConfiguration(); var app = new HomeApplication(); app.StartServices(config); // finalize void Shutdown() { System.Console.WriteLine("\nApplication is shutting down..."); app.StopServices(); System.Console.WriteLine("Done"); } AssemblyLoadContext.Default.Unloading += context => { Shutdown(); }; System.Console.CancelKeyPress += (sender, eventArgs) => { Shutdown(); }; // wait System.Console.WriteLine("Service is available. Press Ctrl+C to exit."); var done = new AutoResetEvent(false); done.WaitOne(); }
private static void TestServer() { HomeEnvironment.Init(); var app = new HomeApplication(); app.Init(); app.StartServices(); Console.WriteLine("Service is available. Press ENTER to exit."); Console.ReadLine(); app.StopServices(); }
private static void TestServer() { var path = typeof(Program).Assembly.Location; var currentDirectory = Path.GetDirectoryName(path); Directory.SetCurrentDirectory(currentDirectory); var app = new HomeApplication(); app.Init(); app.StartServices(); Console.WriteLine("Service is available. Press ENTER to exit."); Console.ReadLine(); app.StopServices(); }
protected override void OnStop() { app.StopServices(); }