protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { try { // You must run CleanArchitecture.Api and Client.WorkerService together. Console.WriteLine("Hello World!"); string baseUrl = "https://*****:*****@test.com", Password = "******" }, stoppingToken); if (result.Succeeded) { CitiesClient citiesClient = new CitiesClient(baseUrl); citiesClient.SetBearerToken(result.Data.Token); var res = await citiesClient.GetAllCitiesAsync(stoppingToken); //consume a webApi get action foreach (var item in res.Data) { Console.WriteLine($"City: { item.Name} "); foreach (var dist in item.Districts) { Console.WriteLine($"District: { dist.Name} "); } } Console.WriteLine(); } } catch (Exception ex) { _logger.LogInformation("Error Message: ", ex); } _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(10000, stoppingToken); } }