Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using Microsoft.Extensions.Hosting;
- namespace Heloworld.Services
- {
- public class HelloWorldConsoleService : BackgroundService
- {
- private readonly IHelloWorldService _helloWorldService;
- private readonly Action _stopApp;
- public HelloWorldConsoleService(IHelloWorldService helloWorldService, Action stopApp)
- {
- _helloWorldService = helloWorldService;
- _stopApp = stopApp;
- }
- protected override Task ExecuteAsync(CancellationToken stoppingToken)
- {
- Console.WriteLine(_helloWorldService.HelloWroldString);
- _stopApp();
- return Task.CompletedTask;
- }
- }
- }
Add Comment
Please, Sign In to add comment