I can imagine a very narrow edge case when waiting task would return just as the previous task releases the semaphore. This delay will prevent this from happening.
This commit is contained in:
Archi
2021-12-28 23:44:12 +01:00
parent cd22d365ea
commit fd05a2cab6

View File

@@ -1893,8 +1893,8 @@ public sealed class Bot : IAsyncDisposable {
return result;
}
private void HandleCallbacks() {
if (!CallbackSemaphore.Wait(0)) {
private async Task HandleCallbacks() {
if (!await CallbackSemaphore.WaitAsync(CallbackSleep)) {
if (Debugging.IsUserDebugging) {
ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(CallbackSemaphore)));
}