2022-03-21 19:11:30 +00:00
|
|
|
|
namespace BirthdayBot.BackgroundServices;
|
2021-10-15 01:55:04 +00:00
|
|
|
|
abstract class BackgroundService {
|
2023-05-28 01:07:45 +00:00
|
|
|
|
protected static SemaphoreSlim ConcurrentSemaphore { get; private set; } = null!;
|
2020-04-02 18:27:55 +00:00
|
|
|
|
|
2023-05-28 01:07:45 +00:00
|
|
|
|
protected ShardInstance Shard { get; }
|
2020-04-02 18:27:55 +00:00
|
|
|
|
|
2023-05-28 01:07:45 +00:00
|
|
|
|
public BackgroundService(ShardInstance instance) {
|
|
|
|
|
Shard = instance;
|
|
|
|
|
ConcurrentSemaphore ??= new SemaphoreSlim(instance.Config.MaxConcurrentOperations);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Log(string message) => Shard.Log(GetType().Name, message);
|
2021-10-15 01:55:04 +00:00
|
|
|
|
|
|
|
|
|
public abstract Task OnTick(int tickCount, CancellationToken token);
|
2020-04-02 18:27:55 +00:00
|
|
|
|
}
|