daily update on 20250122 by nitload youmu, architect rearrange
This commit is contained in:
@@ -41,16 +41,17 @@ namespace StgSharp.Threading
|
||||
public static partial class ThreadHelper
|
||||
{
|
||||
|
||||
private static readonly int mainThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||
private static readonly int mainThreadId = Environment.CurrentManagedThreadId;
|
||||
private static readonly ThreadLocal<bool> isNotMainThread = new ThreadLocal<bool>(
|
||||
() => Thread.CurrentThread.ManagedThreadId != mainThreadId );
|
||||
() => Environment.CurrentManagedThreadId != mainThreadId );
|
||||
|
||||
[Conditional( "DEBUG" )]
|
||||
internal static void MainThreadAssert()
|
||||
{
|
||||
if( isNotMainThread.Value ) {
|
||||
throw new InvalidOperationException(
|
||||
$"Attempt to call sensitive operation which can be only called from main thread " + $"from thread {Thread.CurrentThread.ManagedThreadId}." );
|
||||
$"Attempt to call sensitive operation which can be only called from main thread "
|
||||
+ $"from thread {Environment.CurrentManagedThreadId}." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user