diff --git a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs index 04bb4c317..fec706bd0 100644 --- a/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs +++ b/ArchiSteamFarm/Helpers/CrossProcessFileBasedSemaphore.cs @@ -30,7 +30,7 @@ using ArchiSteamFarm.Core; namespace ArchiSteamFarm.Helpers; internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossProcessSemaphore, IDisposable { - private const ushort SpinLockDelay = 1000; // In milliseconds + private const byte SpinLockDelay = 200; // In milliseconds private readonly string FilePath; private readonly SemaphoreSlim LocalSemaphore = new(1, 1); @@ -125,16 +125,12 @@ internal sealed class CrossProcessFileBasedSemaphore : IAsyncDisposable, ICrossP try { stopwatch.Stop(); - if (stopwatch.ElapsedMilliseconds >= int.MaxValue) { + if (stopwatch.ElapsedMilliseconds >= millisecondsTimeout) { return false; } millisecondsTimeout -= (int) stopwatch.ElapsedMilliseconds; - if (millisecondsTimeout <= 0) { - return false; - } - while (true) { try { // ReSharper disable once SuspiciousLockOverSynchronizationPrimitive - this is not a mistake, we need extra synchronization, and we can re-use the semaphore object for that