using Microsoft.Extensions.Hosting; namespace Connected.Hosting.Workers { /// /// This component acts as a background worker. /// public abstract class Worker : BackgroundService, IWorker { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await OnInvoke(stoppingToken); } protected virtual async Task OnInvoke(CancellationToken cancellationToken) { await Task.CompletedTask; } protected virtual async Task OnError(Exception ex) { await Task.CompletedTask; } } }