private void InitializeProcessThreads() { if (PlatformDetails.RunningOnMacOsx) { return; } CurrentUnmanagedThreadId = NativeMemory.GetCurrentUnmanagedThreadId.Invoke(); CurrentProcess = Process.GetCurrentProcess(); if (PlatformDetails.RunningOnPosix == false) { foreach (ProcessThread pt in CurrentProcess.Threads) { if (pt.Id == (uint)CurrentUnmanagedThreadId) { CurrentProcessThread = pt; break; } } if (CurrentProcessThread == null) { throw new InvalidOperationException("Unable to get the current process thread: " + CurrentUnmanagedThreadId + ", this should not be possible"); } } AffinityHelper.ResetThreadAffinity(this); }
private bool ResetThreadAffinity() { NumberOfCoresToReduce = 0; ThreadMask = null; return(AffinityHelper.ResetThreadAffinity(this)); }
internal void SetThreadAffinity(int numberOfCoresToReduce, long?threadMask) { if (PlatformDetails.RunningOnMacOsx) { return; } NumberOfCoresToReduce = numberOfCoresToReduce; ThreadMask = threadMask; AffinityHelper.SetCustomThreadAffinity(this); }