{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/255","labels_url":"https://api.github.com/repos/aspnet/Hosting/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Hosting/issues/255/comments","events_url":"https://api.github.com/repos/aspnet/Hosting/issues/255/events","html_url":"https://github.com/aspnet/Hosting/pull/255","id":73266892,"number":255,"title":"Third way of making configurable how hosting is kept alive","user":{"login":"Tragetaschen","id":1947968,"avatar_url":"https://avatars.githubusercontent.com/u/1947968?v=3","gravatar_id":"","url":"https://api.github.com/users/Tragetaschen","html_url":"https://github.com/Tragetaschen","followers_url":"https://api.github.com/users/Tragetaschen/followers","following_url":"https://api.github.com/users/Tragetaschen/following{/other_user}","gists_url":"https://api.github.com/users/Tragetaschen/gists{/gist_id}","starred_url":"https://api.github.com/users/Tragetaschen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tragetaschen/subscriptions","organizations_url":"https://api.github.com/users/Tragetaschen/orgs","repos_url":"https://api.github.com/users/Tragetaschen/repos","events_url":"https://api.github.com/users/Tragetaschen/events{/privacy}","received_events_url":"https://api.github.com/users/Tragetaschen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/Hosting/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-05T09:59:56Z","updated_at":"2015-05-05T16:10:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/aspnet/Hosting/pulls/255","html_url":"https://github.com/aspnet/Hosting/pull/255","diff_url":"https://github.com/aspnet/Hosting/pull/255.diff","patch_url":"https://github.com/aspnet/Hosting/pull/255.patch"},"body":"I have tried to incorporate the comments on the other two approaches (#129 and #253) to tackle the problem from yet another angle.\r\n\r\nThis now entirely relies on `IApplicationShutdown` as the method of communication and instead of going back and forth between Program and the keep-alive implementation, the latter is now responsible for doing whatever is required to call `RequestShutdown()`. For things like `Console.CancelKeyPressed`, this is the simplest event handler imaginable.\r\n\r\nAdditionally, it's now possible to register any number of `IHostingKeepAlive` implementations and any one can call `RequestShutdown()` independently.\r\n\r\nThe default implementation can be `IServiceCollection.Replace`d, but keep in mind the open issue and discussion from aspnet/DependencyInjection#155.\r\n\r\nAs a bonus, the implementation in Program.cs is now as simple as it can get.\r\n\r\n@lodejard @davidfowl @victorhurdugaci @HaoK"},"comment":{"url":"https://api.github.com/repos/aspnet/Hosting/issues/comments/99127842","html_url":"https://github.com/aspnet/Hosting/pull/255#issuecomment-99127842","issue_url":"https://api.github.com/repos/aspnet/Hosting/issues/255","id":99127842,"user":{"login":"victorhurdugaci","id":5921642,"avatar_url":"https://avatars.githubusercontent.com/u/5921642?v=3","gravatar_id":"","url":"https://api.github.com/users/victorhurdugaci","html_url":"https://github.com/victorhurdugaci","followers_url":"https://api.github.com/users/victorhurdugaci/followers","following_url":"https://api.github.com/users/victorhurdugaci/following{/other_user}","gists_url":"https://api.github.com/users/victorhurdugaci/gists{/gist_id}","starred_url":"https://api.github.com/users/victorhurdugaci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorhurdugaci/subscriptions","organizations_url":"https://api.github.com/users/victorhurdugaci/orgs","repos_url":"https://api.github.com/users/victorhurdugaci/repos","events_url":"https://api.github.com/users/victorhurdugaci/events{/privacy}","received_events_url":"https://api.github.com/users/victorhurdugaci/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T16:10:20Z","updated_at":"2015-05-05T16:10:20Z","body":"I don't really like the name of the interface `IHostingKeepAlive`. It implies that it is used to keep the hosting alive. It has nothing to do with that.\r\n\r\nIf the implementation doesn't call one of the termination methods, then the code will keep running forever. It would be a keep alive contract if it would block or return a cancellation token."}}