BirthdayBot/BackgroundServices/BackgroundService.cs

16 lines
545 B
C#
Raw Normal View History

2022-03-21 19:11:30 +00:00
namespace BirthdayBot.BackgroundServices;
abstract class BackgroundService {
protected static SemaphoreSlim ConcurrentSemaphore { get; private set; } = null!;
protected ShardInstance Shard { get; }
public BackgroundService(ShardInstance instance) {
Shard = instance;
ConcurrentSemaphore ??= new SemaphoreSlim(instance.Config.MaxConcurrentOperations);
}
protected void Log(string message) => Shard.Log(GetType().Name, message);
public abstract Task OnTick(int tickCount, CancellationToken token);
}