Disable main thread check when framework is shutting down

This commit is contained in:
Haselnussbomber 2025-10-28 01:10:20 +01:00
parent 7a45c0d661
commit ede502677b
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1

View file

@ -1,5 +1,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Dalamud.Game;
namespace Dalamud.Utility; namespace Dalamud.Utility;
/// <summary> /// <summary>
@ -23,7 +25,9 @@ public static class ThreadSafety
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void AssertMainThread(string? message = null) public static void AssertMainThread(string? message = null)
{ {
if (!threadStaticIsMainThread) var isFrameworkUnloading = Service<Framework>.GetNullable()?.IsFrameworkUnloading ?? true;
if (!threadStaticIsMainThread && !isFrameworkUnloading)
{ {
throw new InvalidOperationException(message ?? "Not on main thread!"); throw new InvalidOperationException(message ?? "Not on main thread!");
} }
@ -36,7 +40,9 @@ public static class ThreadSafety
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void AssertNotMainThread() public static void AssertNotMainThread()
{ {
if (threadStaticIsMainThread) var isFrameworkUnloading = Service<Framework>.GetNullable()?.IsFrameworkUnloading ?? true;
if (threadStaticIsMainThread && !isFrameworkUnloading)
{ {
throw new InvalidOperationException("On main thread!"); throw new InvalidOperationException("On main thread!");
} }