added worker service

This commit is contained in:
Nicolas Constant 2020-07-07 01:33:52 -04:00
parent 4457f2c30f
commit 55e04331a0
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
2 changed files with 35 additions and 0 deletions

View file

@ -2,9 +2,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BirdsiteLive.Services;
using Lamar.Microsoft.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@ -23,6 +25,10 @@ namespace BirdsiteLive
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureServices(services =>
{
services.AddHostedService<FederationService>();
});
}
}

View file

@ -0,0 +1,29 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using BirdsiteLive.Domain;
using Microsoft.Extensions.Hosting;
namespace BirdsiteLive.Services
{
public class FederationService : BackgroundService
{
private readonly IUserService _userService;
#region Ctor
public FederationService(IUserService userService)
{
_userService = userService;
}
#endregion
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
for (;;)
{
Console.WriteLine("RUNNING SERVICE");
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
}
}
}
}