Opc.Ua.Configuration.ServiceManager.GetProcessorAffinity C# (CSharp) Method

GetProcessorAffinity() private static method

Gets the processor affinity for the process with the given id.
private static GetProcessorAffinity ( int processId ) : bool[]
processId int
return bool[]
        private static bool[] GetProcessorAffinity(int processId)
        {
            bool[] affinity = new bool[GetNumberOfLogicalProcessors()];
            if (processId > 0)
            {
                try
                {
                    using (System.Diagnostics.Process process = System.Diagnostics.Process.GetProcessById(processId))
                    {
                        IntPtr affinityPtr = process.ProcessorAffinity;
                        int affinityInt = affinityPtr.ToInt32();
                        string affinityStr = Convert.ToString(affinityInt, 2);
                        for (int i = affinityStr.Length - 1; i >= 0; i--)
                        {
                            if (affinityStr[i] == '1')
                            { try { affinity[affinityStr.Length - 1 - i] = true; } catch { } }
                        }
                    }
                }
                catch { }
            }
            return affinity;
        }