Code review

This commit is contained in:
JustArchi
2016-03-06 22:14:02 +01:00
parent b9064bbfda
commit 238cc2ad46
6 changed files with 18 additions and 14 deletions

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);
}