Reliable way to check if current thread is the main thread in console and WPF applications #110141
Unanswered
alexey-leonovich
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to check if current thread is the main thread. I need to support both console and WPF applications - so I cannot check SynchronizationContext.Current or Application.Current.Dispatcher.Thread. An I need to support both .NFW 472 and .NET 8.0.
Thread.CurrentThread.ManagedThreadId
always equals 1?or is it an overkill and there is a simplier solution?
3) Or maybe some extra checks via reflection are needed:
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions