Fix awaiting null tasks, closes #128

This commit is contained in:
JustArchi
2016-03-06 21:49:34 +01:00
parent eddcc2816a
commit b9064bbfda
2 changed files with 11 additions and 4 deletions

View File

@@ -24,9 +24,11 @@
using SteamKit2;
using SteamKit2.Internal;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace ArchiSteamFarm {
internal sealed class ArchiHandler : ClientMsgHandler {
@@ -216,7 +218,7 @@ namespace ArchiSteamFarm {
Client.Send(request);
}
internal AsyncJob<PurchaseResponseCallback> RedeemKey(string key) {
internal async Task<PurchaseResponseCallback> RedeemKey(string key) {
if (string.IsNullOrEmpty(key) || !Client.IsConnected) {
return null;
}
@@ -228,7 +230,12 @@ namespace ArchiSteamFarm {
request.Body.key = key;
Client.Send(request);
return new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
try {
return await new AsyncJob<PurchaseResponseCallback>(Client, request.SourceJobID);
} catch (Exception e) {
Logging.LogGenericException(e);
return null;
}
}
/*

View File

@@ -524,7 +524,7 @@ namespace ArchiSteamFarm {
ArchiHandler.PurchaseResponseCallback result;
try {
result = await currentBot.ArchiHandler.RedeemKey(key);
result = await currentBot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
} catch (Exception e) {
Logging.LogGenericException(e, currentBot.BotName);
break;
@@ -575,7 +575,7 @@ namespace ArchiSteamFarm {
ArchiHandler.PurchaseResponseCallback otherResult;
try {
otherResult = await bot.ArchiHandler.RedeemKey(key);
otherResult = await bot.ArchiHandler.RedeemKey(key).ConfigureAwait(false);
} catch (Exception e) {
Logging.LogGenericException(e, bot.BotName);
break; // We're done with this key