forked from dotnet/aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the Worker template to use
Host.CreateApplicationBuilder
(do…
…tnet#47720) * Update the Worker template to use `Host.CreateApplicationBuilder` The callback approach that `Host.CreateDefaultBuilder` uses is no longer recommended going forward, and the programming model is no longer used in ASP.NET apps - it uses the `WebApplication.CreateBuilder()` API which is imperative, top-to-bottom programming. The Worker template should follow the same pattern. Fix dotnet#43113 * Use var to fit in with ASP.NET.
- Loading branch information
Showing
3 changed files
with
10 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
src/ProjectTemplates/Web.ProjectTemplates/content/Worker-CSharp/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
using Company.Application1; | ||
|
||
IHost host = Host.CreateDefaultBuilder(args) | ||
.ConfigureServices(services => | ||
{ | ||
services.AddHostedService<Worker>(); | ||
}) | ||
.Build(); | ||
var builder = Host.CreateApplicationBuilder(args); | ||
builder.Services.AddHostedService<Worker>(); | ||
|
||
var host = builder.Build(); | ||
host.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters