mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-28 23:19:53 +08:00
添加asynclock尝试修复 asf启动时接收令牌输入卡死问题
This commit is contained in:
@@ -8,6 +8,7 @@ using ArchiSteamFarm.Steam;
|
||||
using ArchiSteamFarm.Steam.Storage;
|
||||
using ArchiSteamFarm.Storage;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Nito.AsyncEx;
|
||||
using NLog;
|
||||
using ReactiveUI;
|
||||
using System.Application.UI;
|
||||
@@ -37,6 +38,8 @@ namespace System.Application.Services.Implementation
|
||||
|
||||
public TaskCompletionSource<string>? ReadLineTask { get; set; }
|
||||
|
||||
private readonly AsyncLock @lock = new AsyncLock();
|
||||
|
||||
bool _IsReadPasswordLine;
|
||||
|
||||
public bool IsReadPasswordLine
|
||||
@@ -69,17 +72,20 @@ namespace System.Application.Services.Implementation
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user