Skip to content

Instantly share code, notes, and snippets.

@IEvangelist
Last active May 24, 2021 02:20
Show Gist options
  • Save IEvangelist/2c2df161c9cdb65fb5a1982a78b05d45 to your computer and use it in GitHub Desktop.
Save IEvangelist/2c2df161c9cdb65fb5a1982a78b05d45 to your computer and use it in GitHub Desktop.
Potential worker service template improvements.
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Example.App;
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services => services.AddHostedService<Worker>())
.Build();
await host.RunAsync();
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Example.App
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
});
}
}
@bradygaster
Copy link

cc @glennc - what do you think of this? I think I like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment