Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance: Using newer Environment.CurrentManagedThreadId for UI/Main thread check #8240

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -315,7 +315,7 @@ public void Stop()

protected void WorkerThreadFrameDispatcher(SynchronizationContext uiThreadSyncContext)
{
Threading.ResetThread(Thread.CurrentThread.ManagedThreadId);
Threading.ResetThread(Environment.CurrentManagedThreadId);
try
{
stopWatch = System.Diagnostics.Stopwatch.StartNew();
Expand Down Expand Up @@ -573,7 +573,7 @@ void processStateForceSurfaceRecreation()
bool RunIteration(CancellationToken token)
{
// set main game thread global ID
Threading.ResetThread(Thread.CurrentThread.ManagedThreadId);
Threading.ResetThread(Environment.CurrentManagedThreadId);

InternalState currentState = InternalState.Exited_GameThread;

Expand Down
4 changes: 2 additions & 2 deletions MonoGame.Framework/Platform/Threading.cs
Expand Up @@ -60,7 +60,7 @@ public struct QueuedAction

static Threading()
{
_mainThreadId = Thread.CurrentThread.ManagedThreadId;
_mainThreadId = Environment.CurrentManagedThreadId;
}

#if ANDROID
Expand All @@ -76,7 +76,7 @@ internal static void ResetThread (int id)
/// <returns>true if the code is currently running on the UI thread.</returns>
public static bool IsOnUIThread()
{
return _mainThreadId == Thread.CurrentThread.ManagedThreadId;
return _mainThreadId == Environment.CurrentManagedThreadId;
}

/// <summary>
Expand Down