Skip to content

Instantly share code, notes, and snippets.

@mirsaeedi
Last active January 19, 2021 04:10
Show Gist options
  • Save mirsaeedi/806842e356b979bea213368343633da7 to your computer and use it in GitHub Desktop.
Save mirsaeedi/806842e356b979bea213368343633da7 to your computer and use it in GitHub Desktop.
Register Hosted Service
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureServices(services =>
{
services.AddHostedService<VideosWatcher>();
services.Configure<HostOptions>(option =>
{
option.ShutdownTimeout = TimeSpan.FromSeconds(30);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment