diff --git a/AccessQueuePlayground/Components/Pages/Home.razor b/AccessQueuePlayground/Components/Pages/Home.razor index 756860b..fbfe951 100644 --- a/AccessQueuePlayground/Components/Pages/Home.razor +++ b/AccessQueuePlayground/Components/Pages/Home.razor @@ -38,7 +38,7 @@ - + @@ -59,7 +59,7 @@ - + diff --git a/AccessQueuePlayground/Services/AccessQueueBackgroundService.cs b/AccessQueuePlayground/Services/AccessQueueBackgroundService.cs index b4cf858..1211271 100644 --- a/AccessQueuePlayground/Services/AccessQueueBackgroundService.cs +++ b/AccessQueuePlayground/Services/AccessQueueBackgroundService.cs @@ -7,27 +7,22 @@ namespace AccessQueuePlayground.Services public class AccessQueueBackgroundService : BackgroundService { private readonly IAccessQueueManager _accessQueueManager; + private readonly IConfiguration _config; - public AccessQueueBackgroundService(IAccessQueueManager accessQueueManager) + public AccessQueueBackgroundService(IAccessQueueManager accessQueueManager, IConfiguration config) { _accessQueueManager = accessQueueManager; + _config = config; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { + int refreshRate = _config.GetValue("AccessQueuePlayground:RefreshRateMilliseconds"); while (!stoppingToken.IsCancellationRequested) { - try - { - await _accessQueueManager.RecalculateStatus(); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - await Task.Delay(100, stoppingToken); // Run every second + await _accessQueueManager.RecalculateStatus(); + await Task.Delay(refreshRate, stoppingToken); } - Console.WriteLine("Stopping now because who tf knows why"); } } } diff --git a/AccessQueuePlayground/appsettings.json b/AccessQueuePlayground/appsettings.json index fcc9c4b..9cfd1aa 100644 --- a/AccessQueuePlayground/appsettings.json +++ b/AccessQueuePlayground/appsettings.json @@ -11,5 +11,8 @@ "ExpirationSeconds": 10, // 12 hours - Time before a user access is revoked "RollingExpiration": true // Whether to extend expiration time on access }, + "AccessQueuePlayground": { + "RefreshRateMilliseconds": 200 // How often to re-request access and update the UI + }, "AllowedHosts": "*" }