// Slow path executed once per thread private static RuntimeThread InitializeExistingThread(bool threadPoolThread) { Debug.Assert(t_currentThread == null); var currentThread = new RuntimeThread(); currentThread._managedThreadId = System.Threading.ManagedThreadId.GetCurrentThreadId(); Debug.Assert(currentThread._threadState == (int)ThreadState.Unstarted); ThreadState state = threadPoolThread ? ThreadPoolThread : 0; // The main thread is foreground, other ones are background if (currentThread._managedThreadId.Id != System.Threading.ManagedThreadId.IdMainThread) { state |= ThreadState.Background; } currentThread._threadState = (int)(state | ThreadState.Running); currentThread.PlatformSpecificInitializeExistingThread(); currentThread._priority = currentThread.GetPriorityLive(); t_currentThread = currentThread; if (threadPoolThread) { InitializeCom(); } return(currentThread); }
// Slow path executed once per thread private static RuntimeThread InitializeExistingThread() { var currentThread = new RuntimeThread(); currentThread._managedThreadId = System.Threading.ManagedThreadId.GetCurrentThreadId(); Debug.Assert(currentThread._threadState == (int)ThreadState.Unstarted); // The main thread is foreground, other ones are background if (currentThread._managedThreadId.Id == System.Threading.ManagedThreadId.IdMainThread) { currentThread._threadState = (int)(ThreadState.Running); } else { currentThread._threadState = (int)(ThreadState.Running | ThreadState.Background); } currentThread.PlatformSpecificInitializeExistingThread(); currentThread._priority = currentThread.GetPriorityLive(); t_currentThread = currentThread; return(currentThread); }