Handle when Process V2 isn't available

This commit is contained in:
2023-04-03 08:23:20 -04:00
parent ebd9dc607b
commit eebd23f702
3 changed files with 31 additions and 10 deletions

View File

@@ -28,6 +28,8 @@ namespace ProcessCpuUsageStatusWindow
public Dictionary<string, ProcessCpuUsage> CurrentProcessList;
public bool IsV2 => _processCategory.CategoryName == "Process V2";
#endregion
#region Initialize and terminate
@@ -40,7 +42,8 @@ namespace ProcessCpuUsageStatusWindow
CurrentProcessList = new Dictionary<string, ProcessCpuUsage>();
// Get the category for process performance info
_processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process V2");
_processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process V2") ??
PerformanceCounterCategory.GetCategories().FirstOrDefault(category => category.CategoryName == "Process");
if (_processCategory == null)
return;