示例#1
0
文件: Program.cs 项目: wadimk/system
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        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();
 }