You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Hosting/Workers/Worker.cs

26 lines
551 B

2 years ago
using Microsoft.Extensions.Hosting;
namespace Connected.Hosting.Workers
{
/// <summary>
/// This component acts as a background worker.
/// </summary>
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;
}
}
}