GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix: resolve cpu and memory component crash (#374)
blam874cd0d95cf7
diff --git a/GlazeWM.Infrastructure/WindowsApi/CpuStatsService.cs b/GlazeWM.Infrastructure/WindowsApi/CpuStatsService.csindex fddb53e6..eabedaff 100644--- a/GlazeWM.Infrastructure/WindowsApi/CpuStatsService.cs+++ b/GlazeWM.Infrastructure/WindowsApi/CpuStatsService.cs@@ -30,7 +30,14 @@ namespace GlazeWM.Infrastructure.WindowsApi/// </summary>public double GetCpuUsage(){- return _cpuCounter.Observe();+ try+ {+ return _cpuCounter.Observe();+ }+ catch+ {+ return 0;+ }}}}diff --git a/GlazeWM.Infrastructure/WindowsApi/MemoryStatsService.cs b/GlazeWM.Infrastructure/WindowsApi/MemoryStatsService.csindex 9ef0e3c0..27fabe7a 100644--- a/GlazeWM.Infrastructure/WindowsApi/MemoryStatsService.cs+++ b/GlazeWM.Infrastructure/WindowsApi/MemoryStatsService.cs@@ -29,8 +29,15 @@ namespace GlazeWM.Infrastructure.WindowsApi/// </summary>public double GetMemoryUsage(){- var percent = (_physicalBytes - _availableBytes.Observe()) / _physicalBytes;- return percent * 100;+ try+ {+ var percent = (_physicalBytes - _availableBytes.Observe()) / _physicalBytes;+ return percent * 100;+ }+ catch+ {+ return 0;+ }}}}