using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Squirrowse.Client.Service; namespace Squirrowse.Client { public class Worker : BackgroundService { private readonly ILogger logger; private readonly IStreamService streamService; private readonly ICameraService camera; public Worker(ILogger logger, IStreamService streamService, ICameraService camera) { this.logger = logger; this.streamService = streamService; this.camera = camera; } protected override async Task ExecuteAsync(CancellationToken stoppingToken) { logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await streamService.SendStreamAsync(camera.GetFramesAsyncEnumerator()); // await Task.Delay(1000, stoppingToken); } } }