Skip to content

Commit

Permalink
添加asynclock尝试修复 asf启动时接收令牌输入卡死问题
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Aug 14, 2022
1 parent df2f84f commit fccd8da
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/ST.Client/Services/Implementation/ArchiSteamFarmServiceImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using ArchiSteamFarm.Steam.Storage;
using ArchiSteamFarm.Storage;
using Microsoft.Extensions.Configuration;
using Nito.AsyncEx;
using NLog;
using ReactiveUI;
using System.Application.UI;
Expand Down Expand Up @@ -37,6 +38,8 @@ public ArchiSteamFarmServiceImpl()

public TaskCompletionSource<string>? ReadLineTask { get; set; }

private readonly AsyncLock @lock = new AsyncLock();

bool _IsReadPasswordLine;

public bool IsReadPasswordLine
Expand Down Expand Up @@ -69,17 +72,20 @@ public async Task<bool> Start(string[]? args = null)

ArchiSteamFarm.NLog.Logging.GetUserInputFunc = async (bool isPassword) =>
{
ReadLineTask = new(TaskCreationOptions.AttachedToParent);
IsReadPasswordLine = isPassword;
using (await @lock.LockAsync())
{
ReadLineTask = new(TaskCreationOptions.AttachedToParent);
IsReadPasswordLine = isPassword;
#if NET6_0_OR_GREATER
var result = await ReadLineTask.Task.WaitAsync(TimeSpan.FromSeconds(60));
var result = await ReadLineTask.Task.WaitAsync(TimeSpan.FromSeconds(60));
#else
var result = await ReadLineTask.Task;
var result = await ReadLineTask.Task;
#endif
if (IsReadPasswordLine)
IsReadPasswordLine = false;
ReadLineTask = null;
return result;
if (IsReadPasswordLine)
IsReadPasswordLine = false;
ReadLineTask = null;
return result;
}
};

await ReadEncryptionKeyAsync();
Expand Down

0 comments on commit fccd8da

Please sign in to comment.