Snowflake/RPG.Services.Core/RPGServiceBase.cs

25 lines
595 B
C#
Raw Normal View History

2024-01-18 16:18:25 +00:00
using Microsoft.Extensions.Hosting;
namespace RPG.Services.Core;
public abstract class RPGServiceBase : IHostedService
{
2024-01-18 22:13:40 +00:00
private readonly ServiceManager _serviceManager;
public RPGServiceBase(ServiceManager serviceManager)
{
_serviceManager = serviceManager;
}
2024-01-18 16:18:25 +00:00
public virtual Task StartAsync(CancellationToken cancellationToken)
{
2024-01-18 22:13:40 +00:00
_serviceManager.Start();
return Task.CompletedTask;
2024-01-18 16:18:25 +00:00
}
2024-01-18 22:13:40 +00:00
public virtual async Task StopAsync(CancellationToken cancellationToken)
2024-01-18 16:18:25 +00:00
{
2024-01-18 22:13:40 +00:00
await _serviceManager.ShutdownAsync();
2024-01-18 16:18:25 +00:00
}
}