KafkaSR/RPG.Services.Core/RPGServiceBase.cs

25 lines
595 B
C#
Raw Normal View History

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