mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-11 14:14:22 +00:00
Code review
This commit is contained in:
@@ -134,7 +134,7 @@ namespace ArchiSteamFarm {
|
||||
bool? isLoggedIn = await IsLoggedIn().ConfigureAwait(false);
|
||||
if (isLoggedIn.HasValue && !isLoggedIn.Value) {
|
||||
Logging.LogGenericInfo("Reconnecting because our sessionID expired!", Bot.BotName);
|
||||
var restart = Task.Run(async () => await Bot.Restart().ConfigureAwait(false));
|
||||
Task.Run(async () => await Bot.Restart().ConfigureAwait(false)).Forget();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
if (!KeepRunning) {
|
||||
KeepRunning = true;
|
||||
var handleCallbacks = Task.Run(() => HandleCallbacks());
|
||||
Task.Run(() => HandleCallbacks()).Forget();
|
||||
}
|
||||
|
||||
Logging.LogGenericInfo("Starting...", BotName);
|
||||
@@ -1183,7 +1183,7 @@ namespace ArchiSteamFarm {
|
||||
|
||||
Trading.CheckTrades();
|
||||
|
||||
var start = Task.Run(async () => await CardsFarmer.StartFarming().ConfigureAwait(false));
|
||||
Task.Run(async () => await CardsFarmer.StartFarming().ConfigureAwait(false)).Forget();
|
||||
break;
|
||||
case EResult.NoConnection:
|
||||
case EResult.ServiceUnavailable:
|
||||
|
||||
@@ -51,12 +51,14 @@ namespace ArchiSteamFarm {
|
||||
internal CardsFarmer(Bot bot) {
|
||||
Bot = bot;
|
||||
|
||||
Timer = new Timer(
|
||||
async e => await CheckGamesForFarming().ConfigureAwait(false),
|
||||
null,
|
||||
TimeSpan.FromMinutes(15), // Delay
|
||||
TimeSpan.FromMinutes(60) // Period
|
||||
);
|
||||
if (Timer == null) {
|
||||
Timer = new Timer(
|
||||
async e => await CheckGamesForFarming().ConfigureAwait(false),
|
||||
null,
|
||||
TimeSpan.FromMinutes(15), // Delay
|
||||
TimeSpan.FromMinutes(60) // Period
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
internal static List<uint> GetGamesToFarmSolo(ConcurrentDictionary<uint, float> gamesToFarm) {
|
||||
@@ -98,7 +100,7 @@ namespace ArchiSteamFarm {
|
||||
await StopFarming().ConfigureAwait(false);
|
||||
} else {
|
||||
Logging.LogGenericInfo("Now running in Automatic Farming mode", Bot.BotName);
|
||||
var start = Task.Run(async () => await StartFarming().ConfigureAwait(false));
|
||||
Task.Run(async () => await StartFarming().ConfigureAwait(false)).Forget();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -104,10 +104,10 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal static async Task LimitSteamRequestsAsync() {
|
||||
await SteamSemaphore.WaitAsync().ConfigureAwait(false);
|
||||
var releaseLater = Task.Run(async () => {
|
||||
Task.Run(async () => {
|
||||
await Utilities.SleepAsync(7000).ConfigureAwait(false); // We must add some delay to not get caught by Steam rate limiter
|
||||
SteamSemaphore.Release();
|
||||
});
|
||||
}).Forget();
|
||||
}
|
||||
|
||||
internal static string GetUserInput(string botLogin, EUserInputType userInputType, string extraInformation = null) {
|
||||
|
||||
@@ -39,10 +39,10 @@ namespace ArchiSteamFarm {
|
||||
|
||||
internal static async Task LimitInventoryRequestsAsync() {
|
||||
await InventorySemaphore.WaitAsync().ConfigureAwait(false);
|
||||
var releaseLater = Task.Run(async () => {
|
||||
Task.Run(async () => {
|
||||
await Utilities.SleepAsync(3000).ConfigureAwait(false); // We must add some delay to not get caught by Steam rate limiter
|
||||
InventorySemaphore.Release();
|
||||
});
|
||||
}).Forget();
|
||||
}
|
||||
|
||||
internal Trading(Bot bot) {
|
||||
|
||||
@@ -27,6 +27,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ArchiSteamFarm {
|
||||
internal static class Utilities {
|
||||
internal static void Forget(this Task task) { }
|
||||
|
||||
internal static async Task SleepAsync(int miliseconds) {
|
||||
await Task.Delay(miliseconds).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user