コード例 #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

                await UsersController.GetUsers();

                UsersController.SaveUsersToDB();
                _logger.LogInformation("Saved Users");

                await PostsController.GetPosts();

                PostsController.SavePostsToDB();
                _logger.LogInformation("Saved Posts");

                await CommentsController.GetComments();

                CommentsController.SaveCommentsToDB();
                _logger.LogInformation("Saved Comments");

                await AlbumsController.GetAlbums();

                AlbumsController.SaveAlbumsToDB();
                _logger.LogInformation("Saved Albums");

                await PhotosController.GetPhotos();

                PhotosController.SavePhotosToDB();
                _logger.LogInformation("Saving Photos");

                await TodosController.GetTodos();

                TodosController.SaveTodosToDB();
                _logger.LogInformation("Saving Todos");

                await Task.Delay(DelayInSeconds * 1000, stoppingToken);
            }
        }