示例#1
0
            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);
            }
示例#2
0
            private bool ResetThreadAffinity()
            {
                NumberOfCoresToReduce = 0;
                ThreadMask            = null;

                return(AffinityHelper.ResetThreadAffinity(this));
            }
示例#3
0
            internal void SetThreadAffinity(int numberOfCoresToReduce, long?threadMask)
            {
                if (PlatformDetails.RunningOnMacOsx)
                {
                    return;
                }

                NumberOfCoresToReduce = numberOfCoresToReduce;
                ThreadMask            = threadMask;

                AffinityHelper.SetCustomThreadAffinity(this);
            }