protected override void OnStop() { if (server != null) { server.Stop(); server.Dispose(); server = null; } }
private int RunAsApplication(AmbienceServerConfiguration configuration) { ManualResetEvent waitHandle = new ManualResetEvent(false); Console.Cancel += delegate { waitHandle.Set(); }; Console.IsCancelationEnabled = true; ShowBanner(); using (AmbienceServer server = new AmbienceServer(configuration)) { Console.WriteLine("Starting..."); server.Start(); Console.WriteLine("Running... (Press Ctrl-C to stop)"); waitHandle.WaitOne(); Console.WriteLine("Stopping..."); server.Stop(); Console.WriteLine("Stopped."); } return(ResultCode.Success); }