Last active
September 17, 2024 02:46
Revisions
-
poojarsn revised this gist
Sep 17, 2024 . 1 changed file with 2 additions and 2 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ public class SomeSingletonService(IServiceScopeFactory serviceScopeFactory) : SingletonService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { -
poojarsn created this gist
Sep 17, 2024 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ public class BackgroundJob(IServiceScopeFactory serviceScopeFactory) : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { using IServiceScope scope = serviceScopeFactory.CreateScope(); var dbContext = scope .ServiceProvider .GetRequiredService<ApplicationDbContext>(); // Do some background processing with the EF database context. await DoWorkAsync(dbContext); } }