Fix tickCount incrementing more than once per tick

This commit is contained in:
Noi 2023-12-08 20:45:40 -08:00
parent 41def830c4
commit 85bb07ed96

View file

@ -57,11 +57,11 @@ class ShardBackgroundWorker : IDisposable {
if (Instance.DiscordClient.ConnectionState != ConnectionState.Connected) continue; if (Instance.DiscordClient.ConnectionState != ConnectionState.Connected) continue;
// Execute tasks sequentially // Execute tasks sequentially
_tickCount++;
foreach (var service in _workers) { foreach (var service in _workers) {
CurrentExecutingService = service.GetType().Name; CurrentExecutingService = service.GetType().Name;
try { try {
if (_workerCanceller.IsCancellationRequested) break; if (_workerCanceller.IsCancellationRequested) break;
_tickCount++;
await service.OnTick(_tickCount, _workerCanceller.Token); await service.OnTick(_tickCount, _workerCanceller.Token);
} catch (Exception ex) when (ex is not } catch (Exception ex) when (ex is not
(TaskCanceledException or OperationCanceledException or ObjectDisposedException)) { (TaskCanceledException or OperationCanceledException or ObjectDisposedException)) {