diff --git a/HSMonitor/Services/SerialMonitorService.cs b/HSMonitor/Services/SerialMonitorService.cs index 4a5c9c7..bcec82c 100644 --- a/HSMonitor/Services/SerialMonitorService.cs +++ b/HSMonitor/Services/SerialMonitorService.cs @@ -27,7 +27,7 @@ public SerialMonitorService( _serial = new Serial(settingsService); _settingsService.SettingsSaved += (_, _) => UpdateSerialSettings(); - _hardwareMonitorService.HardwareInformationUpdated += (_, _) => SendInformationToMonitor(); + _hardwareMonitorService.HardwareInformationUpdated += SendInformationToMonitor; } private void UpdateSerialSettings() @@ -36,9 +36,10 @@ private void UpdateSerialSettings() _serial = new Serial(_settingsService ?? throw new InvalidOperationException()); } - private void SendInformationToMonitor() + private void SendInformationToMonitor(object? sender, EventArgs args) { - var message = _hardwareMonitorService.GetHwInfoMessage() ?? throw new Exception("Message empty"); + if (sender is not HardwareMonitorService hardwareMonitorService) return; + var message = hardwareMonitorService.GetHwInfoMessage() ?? throw new Exception("Message empty"); if (_settingsService.Settings.IsDeviceBackwardCompatibilityEnabled) { if (message.CpuInformation is {Name.Length: > 23})