Don't launch all parallel tasks immediately

It seems that the runtime is actually smarter than I thought, and can optimize tasks creation for maximum performance better than we'd do
This commit is contained in:
JustArchi
2016-07-02 22:05:29 +02:00
parent ab4630c191
commit cbf212aff5
2 changed files with 3 additions and 7 deletions

View File

@@ -276,8 +276,7 @@ namespace ArchiSteamFarm {
}
if ((acceptedSteamID != 0) || ((acceptedTradeIDs != null) && (acceptedTradeIDs.Count > 0))) {
List<Task<Steam.ConfirmationDetails>> tasks = confirmations.Select(BotDatabase.MobileAuthenticator.GetConfirmationDetails).ToList();
Steam.ConfirmationDetails[] detailsResults = await Task.WhenAll(tasks).ConfigureAwait(false);
Steam.ConfirmationDetails[] detailsResults = await Task.WhenAll(confirmations.Select(BotDatabase.MobileAuthenticator.GetConfirmationDetails)).ConfigureAwait(false);
HashSet<uint> ignoredConfirmationIDs = new HashSet<uint>();
foreach (Steam.ConfirmationDetails details in detailsResults.Where(details => (details != null) && (
@@ -761,8 +760,7 @@ namespace ArchiSteamFarm {
return null;
}
List<Task<string>> tasks = Bots.Values.Select(bot => bot.ResponseLoot(steamID)).ToList();
await Task.WhenAll(tasks).ConfigureAwait(false);
await Task.WhenAll(Bots.Values.Select(bot => bot.ResponseLoot(steamID))).ConfigureAwait(false);
return "Done!";
}

View File

@@ -107,9 +107,7 @@ namespace ArchiSteamFarm {
}
}
List<Task<ParseTradeResult>> tasks = tradeOffers.Select(ParseTrade).ToList();
ParseTradeResult[] results = await Task.WhenAll(tasks).ConfigureAwait(false);
ParseTradeResult[] results = await Task.WhenAll(tradeOffers.Select(ParseTrade)).ConfigureAwait(false);
if (results.Any(result => result == ParseTradeResult.AcceptedWithItemLose)) {
await Task.Delay(1000).ConfigureAwait(false); // Sometimes we can be too fast for Steam servers to generate confirmations, wait a short moment
HashSet<ulong> tradeIDs = new HashSet<ulong>(tradeOffers.Select(tradeOffer => tradeOffer.TradeOfferID));