Skip to content

Commit

Permalink
🎨 asf 路径修改启动问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzaz committed Nov 15, 2023
1 parent d433d60 commit a7572ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ private async Task<bool> StartProcess()
options.ArgumentList.Add(EncryptionKey);
}
ASFProcess = Process.Start(options);

ASFService.Current.ConsoleLogText = string.Empty;
ThreadPool.QueueUserWorkItem(ReadOutPutData);
AppDomain.CurrentDomain.ProcessExit += ExitHandler;
AppDomain.CurrentDomain.UnhandledException += ExitHandler;

ASFProcess!.ErrorDataReceived += new DataReceivedEventHandler(ExitHandler);
ASFProcess.BeginErrorReadLine();
while (!SocketHelper.IsUsePort(CurrentIPCPortValue))
Expand Down Expand Up @@ -227,11 +230,12 @@ private async void ReadOutPutData(object? obj)
{
int readResult;
char ch;
var len = string.Empty;
StringBuilder sb = new();
var len = string.Empty;

while (true)
{
Task<int> readAsync = Task.Run(sr.Read);
var readAsync = Task.Run(sr.Read);

await Task.WhenAny(readAsync, Task.Delay(TimeSpan.FromSeconds(3)));

Expand Down Expand Up @@ -287,7 +291,7 @@ public async Task StopAsync()
ReadLineTask?.TrySetResult("");
if (ASFProcess != null)
{
await webApiService.ASF.Exit();
await Task.WhenAny(webApiService.ASF.Exit(), Task.Delay(TimeSpan.FromSeconds(3)));
ASFProcess.Kill();
ASFProcess.Dispose();
ASFProcess = null;
Expand Down Expand Up @@ -407,9 +411,7 @@ public int CurrentIPCPortValue
{
if (_currentIpcPortValue == default)
{
_currentIpcPortValue = ASFSettings.IPCPortId.Value != default(int)
? ASFSettings.IPCPortId.Value
: ASFSettings.DefaultIPCPortIdValue;
_currentIpcPortValue = ASFSettings.IPCPortId.Value;

if (ASFSettings.IPCPortOccupiedRandom.Value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public async Task InitASFCoreAsync(bool showToast)
if (!isOk)
{
if (showToast) Toast.Show(ToastIcon.Error, AppResources.ASF_Stoped, ToastLength.Short);
IsASFRunOrStoping = false;
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ internal static string DirCreateByNotExists(string dirPath)
return dirPath;
}

private static string _ASFExecuteFilePath = ASFSettings.ArchiSteamFarmExePath.Value ?? string.Empty;
private static string ASFSettingsExecuteFilePath { get { return ASFSettings.ArchiSteamFarmExePath.Value ?? string.Empty; } }

internal static string ASFExecuteFilePath
{
get
{
if (!string.IsNullOrEmpty(_ASFExecuteFilePath) && File.Exists(_ASFExecuteFilePath))
if (!string.IsNullOrEmpty(ASFSettingsExecuteFilePath) && File.Exists(ASFSettingsExecuteFilePath))
{
Version = new Version(FileVersionInfo.GetVersionInfo(_ASFExecuteFilePath)?.FileVersion ?? string.Empty);
return _ASFExecuteFilePath;
Version = new Version(FileVersionInfo.GetVersionInfo(ASFSettingsExecuteFilePath)?.FileVersion ?? string.Empty);
return ASFSettingsExecuteFilePath;
}
return string.Empty;
}
Expand All @@ -32,7 +32,7 @@ internal static string HomeDirectory
{
get
{
return Path.GetDirectoryName(_ASFExecuteFilePath);
return Path.GetDirectoryName(ASFSettingsExecuteFilePath) ?? string.Empty;
}
}

Expand Down

0 comments on commit a7572ec

Please sign in to comment.