mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Improve flow and get rid of synchronous sleeps
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user