added worker service
This commit is contained in:
parent
4457f2c30f
commit
55e04331a0
2 changed files with 35 additions and 0 deletions
|
@ -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>();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
29
src/BirdsiteLive/Services/FederationService.cs
Normal file
29
src/BirdsiteLive/Services/FederationService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue