Tag: 武士刀

停止自托管owin服务器时完成当前请求

我有OWIN服务器作为控制台应用程序的一部分。 你可以在这里看到主要方法: class Program { public static ManualResetEventSlim StopSwitch = new ManualResetEventSlim(); static void Main(string[] args) { Console.CancelKeyPress += (s, a) => { a.Cancel = true; StopSwitch.Set(); }; using (WebApp.Start(“http://+:8080/”)) { Console.WriteLine(“Server is running…”); Console.WriteLine(“Press CTRL+C to stop it.”); StopSwitch.Wait(); Console.WriteLine(“Server is stopping…”); } Console.ReadKey(); Console.WriteLine(“Server stopped. Press any key to close app…”); } } […]