From 9234925c1a1f4a03a2f31a76d1025f2c92ede723 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 2 Jul 2025 18:23:14 +0200 Subject: [PATCH] check for executingjob --- src/Sentry.Unity/MainThreadData.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Sentry.Unity/MainThreadData.cs b/src/Sentry.Unity/MainThreadData.cs index 69a9451eb..e29a2d394 100644 --- a/src/Sentry.Unity/MainThreadData.cs +++ b/src/Sentry.Unity/MainThreadData.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using Unity.Jobs.LowLevel.Unsafe; using UnityEngine; namespace Sentry.Unity; @@ -70,7 +71,7 @@ internal static class MainThreadData public static DateTimeOffset? StartTime { get; set; } public static bool IsMainThread() - => MainThreadId.HasValue && Thread.CurrentThread.ManagedThreadId == MainThreadId; + => !JobsUtility.IsExecutingJob && MainThreadId.HasValue && Thread.CurrentThread.ManagedThreadId == MainThreadId; // For testing internal static ISentrySystemInfo? SentrySystemInfo { get; set; }