Processor.cs 895 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. namespace SmartCoalApplication.SystemLayer
  3. {
  4. public static class Processor
  5. {
  6. private static int logicalCpuCount;
  7. static Processor()
  8. {
  9. logicalCpuCount = ConcreteLogicalCpuCount;
  10. }
  11. public static int LogicalCpuCount
  12. {
  13. get
  14. {
  15. return logicalCpuCount;
  16. }
  17. set
  18. {
  19. if (value < 1 || value > (IntPtr.Size * 8))
  20. {
  21. throw new ArgumentOutOfRangeException("value", value, "must be in the range [0, " + (IntPtr.Size * 8).ToString() + "]");
  22. }
  23. logicalCpuCount = value;
  24. }
  25. }
  26. public static int ConcreteLogicalCpuCount
  27. {
  28. get
  29. {
  30. return Environment.ProcessorCount;
  31. }
  32. }
  33. }
  34. }