diff --git a/CodeLegacy/Os/OsUtils.cs b/CodeLegacy/Os/OsUtils.cs index 5090a49..dd93768 100644 --- a/CodeLegacy/Os/OsUtils.cs +++ b/CodeLegacy/Os/OsUtils.cs @@ -333,5 +333,19 @@ namespace Flowframes.Os return string.Join(";", newPaths.Select(x => x.Replace("\\", "/"))) + ";"; } + + public static bool IsStillRunning(Func proc) // For .NET Core migration: Func (nullable) + { + var p = proc(); // Snapshot of the process to avoid race condition + + try + { + return p is null || !p.HasExited; + } + catch + { + return false; + } + } } } \ No newline at end of file diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs index f686538..42b851d 100644 --- a/CodeLegacy/Program.cs +++ b/CodeLegacy/Program.cs @@ -182,7 +182,7 @@ namespace Flowframes // Logger.Log($"Disk space check for '{drivePath}/': {spaceGb} GB free, next check in {nextWaitTimeMs / 1024} sec", true); - if (!Interpolate.canceled && (AiProcess.lastAiProcess != null && !AiProcess.lastAiProcess.HasExited) && lowDiskSpace) + if (!Interpolate.canceled && OsUtils.IsStillRunning(() => AiProcess.lastAiProcess) && lowDiskSpace) { if (tooLowDiskSpace) {