From ede502677bb09af4dcafff441b29defbd32e1f03 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Tue, 28 Oct 2025 01:10:20 +0100 Subject: [PATCH] Disable main thread check when framework is shutting down --- Dalamud/Utility/ThreadSafety.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dalamud/Utility/ThreadSafety.cs b/Dalamud/Utility/ThreadSafety.cs index c31cc0005..7ce6a0776 100644 --- a/Dalamud/Utility/ThreadSafety.cs +++ b/Dalamud/Utility/ThreadSafety.cs @@ -1,5 +1,7 @@ using System.Runtime.CompilerServices; +using Dalamud.Game; + namespace Dalamud.Utility; /// @@ -23,7 +25,9 @@ public static class ThreadSafety [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AssertMainThread(string? message = null) { - if (!threadStaticIsMainThread) + var isFrameworkUnloading = Service.GetNullable()?.IsFrameworkUnloading ?? true; + + if (!threadStaticIsMainThread && !isFrameworkUnloading) { throw new InvalidOperationException(message ?? "Not on main thread!"); } @@ -36,7 +40,9 @@ public static class ThreadSafety [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void AssertNotMainThread() { - if (threadStaticIsMainThread) + var isFrameworkUnloading = Service.GetNullable()?.IsFrameworkUnloading ?? true; + + if (threadStaticIsMainThread && !isFrameworkUnloading) { throw new InvalidOperationException("On main thread!"); }