protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { if (await _userAuthService.IsUserAuthenticated()) { try { await GetData(); } catch { } await Task.Delay(Convert.ToInt32(Config.LightSettings.PollingInterval * 1000), stoppingToken); } await Task.Delay(1000, stoppingToken); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { if (!Debugger.IsAttached) { Helpers.OpenBrowser("https://localhost:5001"); } while (!stoppingToken.IsCancellationRequested) { if (await _userAuthService.IsUserAuthenticated()) { try { await GetData(); } catch { } await Task.Delay(Convert.ToInt32(Config.PollingInterval * 1000), stoppingToken); } await Task.Delay(1000, stoppingToken); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { if (await _userAuthService.IsUserAuthenticated()) { _logger.LogInformation("User is Authenticated, starting worker"); try { await Run(); } catch (Exception e) { _logger.LogError(e, "Exception occured restarting worker"); } } else { _logger.LogInformation("User is Not Authenticated, restarting worker"); } await Task.Delay(1000, stoppingToken); } }