mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Improve flow and get rid of synchronous sleeps
This commit is contained in:
parent
f577e1a6cb
commit
b63dd1035c
2 changed files with 6 additions and 11 deletions
|
@ -135,7 +135,7 @@ namespace ArchiSteamFarm {
|
|||
Trading = new Trading(this);
|
||||
|
||||
// Start
|
||||
Start();
|
||||
var fireAndForget = Task.Run(async () => await Start().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
private bool ReadConfig() {
|
||||
|
@ -205,17 +205,18 @@ namespace ArchiSteamFarm {
|
|||
return true;
|
||||
}
|
||||
|
||||
internal void Start() {
|
||||
internal async Task Start() {
|
||||
if (IsRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
IsRunning = true;
|
||||
|
||||
Program.LimitSteamRequests();
|
||||
Logging.LogGenericInfo(BotName, "Starting...");
|
||||
await Program.LimitSteamRequestsAsync().ConfigureAwait(false);
|
||||
SteamClient.Connect();
|
||||
|
||||
Task.Run(() => HandleCallbacks());
|
||||
var fireAndForget = Task.Run(() => HandleCallbacks());
|
||||
}
|
||||
|
||||
internal async Task Stop() {
|
||||
|
@ -530,7 +531,7 @@ namespace ArchiSteamFarm {
|
|||
case EResult.TryAnotherCM:
|
||||
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult + ", retrying...");
|
||||
await Stop().ConfigureAwait(false);
|
||||
Start();
|
||||
await Start().ConfigureAwait(false);
|
||||
break;
|
||||
default:
|
||||
Logging.LogGenericWarning(BotName, "Unable to login to Steam: " + callback.Result + " / " + callback.ExtendedResult);
|
||||
|
|
|
@ -96,12 +96,6 @@ namespace ArchiSteamFarm {
|
|||
SteamSemaphore.Release();
|
||||
}
|
||||
|
||||
internal static void LimitSteamRequests() {
|
||||
SteamSemaphore.Wait();
|
||||
Thread.Sleep(Utilities.GetRandomDelay() * 1000); // We must add some delay to not get caught by Steam anty-DoS
|
||||
SteamSemaphore.Release();
|
||||
}
|
||||
|
||||
internal static string GetUserInput(string botLogin, EUserInputType userInputType) {
|
||||
string result;
|
||||
lock (ConsoleLock) {
|
||||
|
|
Loading…
Reference in a new issue