{"id":621,"date":"2019-09-24T17:58:04","date_gmt":"2019-09-24T08:58:04","guid":{"rendered":"http:\/\/csharp.ihavenomoney.co.kr\/?p=621"},"modified":"2019-09-24T17:58:04","modified_gmt":"2019-09-24T08:58:04","slug":"generic-host","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=621","title":{"rendered":"generic-host"},"content":{"rendered":"<p>\ucef4\ud30c\uc77c \uc624\ub958<\/p>\n<pre class=\"lang:c# decode:true \" >using Microsoft.AspNetCore.Hosting;\r\nusing Microsoft.Extensions.DependencyInjection;\r\nusing System.Threading.Tasks;\r\nusing System.Threading;\r\nusing Microsoft.Extensions.Hosting;\r\nusing System;\r\n\r\nnamespace ConsoleApp2\r\n{\r\n    public class HelloWorldService : IHostedService\r\n    {\r\n        public Task StartAsync(CancellationToken cancellationToken)\r\n        {\r\n            Console.WriteLine(\"Hello world\");\r\n            return Task.CompletedTask;\r\n        }\r\n\r\n        public Task StopAsync(CancellationToken cancellationToken)\r\n        {\r\n            Console.WriteLine(\"Goodbye\");\r\n            return Task.CompletedTask;\r\n        }\r\n    }\r\n\r\n    public class Program\r\n    {\r\n        public static async Task Main(string[] args)\r\n        {\r\n            var host = new HostBuilder()\r\n                .ConfigureServices((hostContext, services) =&gt;\r\n                {\r\n                    services.AddHostedService&lt;HelloWorldService&gt;();\r\n                })\r\n                .Build();\r\n\r\n            await host.RunAsync();\r\n        }\r\n    }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ucef4\ud30c\uc77c \uc624\ub958 using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using System.Threading.Tasks; using System.Threading; using Microsoft.Extensions.Hosting; using System; namespace ConsoleApp2 { public class HelloWorldService : IHostedService { public Task StartAsync(CancellationToken cancellationToken) { Console.WriteLine(&#8220;Hello world&#8221;); return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) { Console.WriteLine(&#8220;Goodbye&#8221;); return Task.CompletedTask; } } public class Program { public static async Task Main(string[] args) { var\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=621\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-621","post","type-post","status-publish","format-standard","hentry","category-net-core"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/621","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=621"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/621\/revisions"}],"predecessor-version":[{"id":622,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/621\/revisions\/622"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}