コード例 #1
0
ファイル: Entry.cs プロジェクト: latipium-old/daemon
        private static bool DebugSwitch(string[] args)
        {
            switch (args.FirstOrDefault())
            {
            case "run":
                using (DaemonWebServer server = new DaemonWebServer()) {
                    server.Start();
                    Console.WriteLine("Application started.");
                    Console.WriteLine("Press any key to stop the server");
                    try {
                        ConsoleKeyInfo key;
                        do
                        {
                            key = Console.ReadKey(true);
                        } while (key.Key == 0 && key.KeyChar == '\0');
                    } catch (Exception) {
                        try {
                            while (true)
                            {
                                Thread.Sleep(int.MaxValue);
                            }
                        } catch (Exception ex) {
                            Console.Error.WriteLine(ex);
                        }
                    }
                    Console.WriteLine("Shutting down server...");
                }
                break;

            default:
                return(false);
            }
            return(true);
        }
コード例 #2
0
 protected override void OnStart(string[] args)
 {
     Instance = this;
     Server   = new DaemonWebServer();
     Server.Start();
 }