private static void Cmd() { var key = System.Console.ReadLine(); var cmds = key.ToLower().Split(' '); if (cmds.Length == 0) { return; } var cmd = cmds[0]; switch (cmd) { case "exit": Csl.Wl("正在关闭应用程序。。。等待最后一个心跳执行完成。。。"); Server.Close(); Csl.Wl("2秒后关闭应用程序。。。"); Thread.Sleep(2000); Process.GetCurrentProcess().CloseMainWindow(); break; case "start": Server.Start(); Cmd(); break; case "gc": { Stopwatch sw = new Stopwatch(); sw.Start(); GC.Collect(); sw.Stop(); Cmd(); break; } default: { Server.Cmd(cmd); Cmd(); break; } return; } }
protected override void OnStop() { _server.Close(); }