protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation("TFT Data Worker running at: {time}", DateTimeOffset.Now); // Obtain current configuration, set tft set to a placeholder configHandler = new ApplicationConfigHandler(); List <Set> allSets = GetSets(out string currentSet); Set[] missingSets = allSets.Where(x => !configHandler.configuration.AllTftSet.Contains(x)).ToArray(); foreach (Set set in missingSets) { string dataDirectory = ExtractLatestSetZip(set.url, set.name); set.isExtracted = false; } // Save the new configuration configHandler.configuration.CurrentTftSet = currentSet; configHandler.configuration.AllTftSet = allSets; configHandler.save(); // Extract Latest Set Data foreach (Set set in allSets) { if (set.isExtracted == false || set.isCurrent) { SetHandler.ExtractDataFromSet(set, configHandler); } } await Task.Delay(2000, stoppingToken); } }