From b6ce8f435c44c50b8a8e81be7507c91de210d915 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Mon, 18 Apr 2016 18:43:58 +0200 Subject: [PATCH] Use more optimized Slim manual reset events --- ArchiSteamFarm/CardsFarmer.cs | 6 +++--- ArchiSteamFarm/Program.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ArchiSteamFarm/CardsFarmer.cs b/ArchiSteamFarm/CardsFarmer.cs index cc4de50e7..84a37bb8d 100755 --- a/ArchiSteamFarm/CardsFarmer.cs +++ b/ArchiSteamFarm/CardsFarmer.cs @@ -37,7 +37,7 @@ namespace ArchiSteamFarm { internal readonly ConcurrentDictionary GamesToFarm = new ConcurrentDictionary(); internal readonly HashSet CurrentGamesFarming = new HashSet(); - private readonly ManualResetEvent FarmResetEvent = new ManualResetEvent(false); + private readonly ManualResetEventSlim FarmResetEvent = new ManualResetEventSlim(false); private readonly SemaphoreSlim Semaphore = new SemaphoreSlim(1); private readonly Bot Bot; private readonly Timer Timer; @@ -421,7 +421,7 @@ namespace ArchiSteamFarm { bool? keepFarming = await ShouldFarm(appID).ConfigureAwait(false); for (ushort farmingTime = 0; farmingTime <= 60 * Program.GlobalConfig.MaxFarmingTime && keepFarming.GetValueOrDefault(true); farmingTime += Program.GlobalConfig.FarmingDelay) { - if (FarmResetEvent.WaitOne(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { + if (FarmResetEvent.Wait(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { success = false; break; } @@ -452,7 +452,7 @@ namespace ArchiSteamFarm { bool success = true; while (maxHour < 2) { - if (FarmResetEvent.WaitOne(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { + if (FarmResetEvent.Wait(60 * 1000 * Program.GlobalConfig.FarmingDelay)) { success = false; break; } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index b8bf8f24b..f94ebb148 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -70,7 +70,7 @@ namespace ArchiSteamFarm { private static readonly object ConsoleLock = new object(); private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1); - private static readonly ManualResetEvent ShutdownResetEvent = new ManualResetEvent(false); + private static readonly ManualResetEventSlim ShutdownResetEvent = new ManualResetEventSlim(false); private static readonly string ExecutableFile = Assembly.Location; private static readonly string ExecutableName = Path.GetFileName(ExecutableFile); private static readonly string ExecutableDirectory = Path.GetDirectoryName(ExecutableFile); @@ -523,7 +523,7 @@ namespace ArchiSteamFarm { Init(args); // Wait for signal to shutdown - ShutdownResetEvent.WaitOne(); + ShutdownResetEvent.Wait(); // We got a signal to shutdown Exit();