internal async Task StopFarming() { if (!NowFarming) { return; } await FarmingSemaphore.WaitAsync().ConfigureAwait(false); if (!NowFarming) { FarmingSemaphore.Release(); return; } Logging.LogGenericInfo("Sending signal to stop farming", Bot.BotName); KeepFarming = false; FarmResetEvent.Set(); Logging.LogGenericInfo("Waiting for reaction...", Bot.BotName); for (byte i = 0; (i < 5) && NowFarming; i++) { await Utilities.SleepAsync(1000).ConfigureAwait(false); } if (NowFarming) { Logging.LogGenericWarning("Timed out!", Bot.BotName); } Logging.LogGenericInfo("Farming stopped!", Bot.BotName); Bot.OnFarmingStopped(); FarmingSemaphore.Release(); }
internal async Task StopFarming() { if (!NowFarming) { return; } await FarmingInitializationSemaphore.WaitAsync().ConfigureAwait(false); try { if (!NowFarming) { return; } KeepFarming = false; if (FarmingResetSemaphore.CurrentCount == 0) { FarmingResetSemaphore.Release(); } for (byte i = 0; (i < WebBrowser.MaxTries) && NowFarming; i++) { await Task.Delay(1000).ConfigureAwait(false); } if (NowFarming) { NowFarming = false; } Bot.ArchiLogger.LogGenericInfo(Strings.IdlingStopped); await Bot.OnFarmingStopped().ConfigureAwait(false); } finally { FarmingInitializationSemaphore.Release(); } }
internal async Task StopFarming() { if (!NowFarming) { return; } await FarmingSemaphore.WaitAsync().ConfigureAwait(false); try { if (!NowFarming) { return; } Bot.ArchiLogger.LogGenericInfo("Sending signal to stop farming"); KeepFarming = false; FarmResetEvent.Set(); Bot.ArchiLogger.LogGenericInfo("Waiting for reaction..."); for (byte i = 0; (i < 5) && NowFarming; i++) { await Task.Delay(1000).ConfigureAwait(false); } if (NowFarming) { Bot.ArchiLogger.LogGenericWarning("Timed out!"); NowFarming = false; } Bot.ArchiLogger.LogGenericInfo("Farming stopped!"); Bot.OnFarmingStopped(); } finally { FarmingSemaphore.Release(); } }