File tree Expand file tree Collapse file tree
aspnetcore/fundamentals/host/hosted-services/samples/3.x/BackgroundTasksSample Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ public class Program
99 {
1010 public static async Task Main ( string [ ] args )
1111 {
12- using ( var host = Host . CreateDefaultBuilder ( args )
12+ using var host = Host . CreateDefaultBuilder ( args )
1313 . ConfigureServices ( ( hostContext , services ) =>
1414 {
1515 #region snippet3
@@ -27,20 +27,16 @@ public static async Task Main(string[] args)
2727 services . AddScoped < IScopedProcessingService , ScopedProcessingService > ( ) ;
2828 #endregion
2929 } )
30- . Build ( ) )
31- {
32- // Start the host
33- await host . StartAsync ( ) ;
30+ . Build ( ) ;
3431
35- // Monitor for new background queue work items
36- #region snippet4
37- var monitorLoop = host . Services . GetRequiredService < MonitorLoop > ( ) ;
38- monitorLoop . StartMonitorLoop ( ) ;
39- #endregion
32+ await host . StartAsync ( ) ;
4033
41- // Wait for the host to shutdown
42- await host . WaitForShutdownAsync ( ) ;
43- }
34+ #region snippet4
35+ var monitorLoop = host . Services . GetRequiredService < MonitorLoop > ( ) ;
36+ monitorLoop . StartMonitorLoop ( ) ;
37+ #endregion
38+
39+ await host . WaitForShutdownAsync ( ) ;
4440 }
4541 }
4642}
You can’t perform that action at this time.
0 commit comments