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.
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|