using System.Runtime.CompilerServices; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.System.Framework; using KamiToolKit.Classes; namespace KamiToolKit.Extensions; public static unsafe class MainThreadSafety { /// /// Returns true if not on the main thread. Use this to return early. /// public static bool TryAssertMainThread([CallerFilePath] string? callerFilePath = null, [CallerMemberName] string? callerName = null) { if (Framework.Instance()->IsDestroying) return true; if (!ThreadSafety.IsMainThread) { Log.Error($"{callerFilePath?.Split(@"\")[^1][..^2]}{callerName} must be invoked from the main thread."); return true; } return false; } }