// ******************************************************************
 private void NonExOnClick(object sender, RoutedEventArgs e)
 {
     SystemInfoHelper.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] results = SystemInfoHelper.GetLogicalProcessorInformation();
 }
Beispiel #2
0
        public void Refresh()
        {
            WmiProcessorCount         = SystemInfoHelper.GetWmiPhysicalProcessorCount();
            WmiGlobalCoreCount        = SystemInfoHelper.GetWmiCoreCount();
            WmiLogicalProcessorCount  = SystemInfoHelper.GetWmiGlobalLogicalProcessorCount();
            NumaHighestNodeNumber     = SystemInfoHelper.GetNumaHighestNodeNumber();
            ActiveProcessorGroupCount = SystemInfoHelper.GetActiveProcessorGroupCount();

            var sb = new StringBuilder();

            for (UInt16 groupIndex = 0; groupIndex < ActiveProcessorGroupCount; groupIndex++)
            {
                if (sb.Length > 0)
                {
                    sb.AppendLine();
                }

                sb.AppendFormat("Group '{0}' as ", groupIndex);

                UInt32 processorCount = SystemInfoHelper.GetActiveProcessorCount(groupIndex);
                if (processorCount == 0)
                {
                    sb.AppendFormat("Error reading GetActiveProcessorCount: {0}", Marshal.GetLastWin32Error());
                }
                else
                {
                    sb.AppendFormat("{0} Logical Processors", processorCount);
                }
            }

            LogicalProcessorCountPerGroup = sb.ToString();

            MaximumProcessorGroupCount             = SystemInfoHelper.GetMaximumProcessorGroupCount();
            CSharpEnvironmentLogicalProcessorCount = Environment.ProcessorCount;

            UInt64 processAffinityMask;
            UInt64 systemAffinityMask;

            bool isResultOk = SystemInfoHelper.GetProcessAffinityMask(
                System.Diagnostics.Process.GetCurrentProcess().Handle,
                out processAffinityMask,
                out systemAffinityMask);

            if (isResultOk)
            {
                ProcessAffinityMask       = processAffinityMask;
                ProcessAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", processAffinityMask,
                                                          GetBitCount(processAffinityMask), GetBitString(processAffinityMask));
                SystemAffinityMask       = systemAffinityMask;
                SystemAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", systemAffinityMask,
                                                         GetBitCount(processAffinityMask), GetBitString(systemAffinityMask));
            }
            else
            {
                int error = Marshal.GetLastWin32Error();

                ProcessAffinityMaskString = "GetProcessAffinityMask() error = " + error;
                SystemAffinityMaskString  = "GetProcessAffinityMask() error = " + error;
            }

            sb.Clear();
            for (int nodeIndex = 0; nodeIndex <= NumaHighestNodeNumber; nodeIndex++)
            {
                UInt64 numaNodeProcessorMask;
                SystemInfoHelper.GetNumaNodeProcessorMask((byte)nodeIndex, out numaNodeProcessorMask);
                sb.Append(String.Format("Node: {0} Processor Mask: {1} (bit count: {2})", nodeIndex, numaNodeProcessorMask, GetBitCount(numaNodeProcessorMask)));
                sb.Append(Environment.NewLine);
                sb.Append(GetBitString(numaNodeProcessorMask));
                sb.Append(Environment.NewLine);
            }

            NumaNodeAndTheirAffinityMask = sb.ToString();

            var structLogProcInfo = SystemInfoHelper.GetLogicalProcessorInformation();
        }