Skip to content

Commit

Permalink
Reworking the system for sending messages to the device
Browse files Browse the repository at this point in the history
  • Loading branch information
TTLC198 committed Sep 9, 2023
1 parent 22b4929 commit 942c3ca
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions HSMonitor/Services/SerialMonitorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public SerialMonitorService(
_serial = new Serial(settingsService);

_settingsService.SettingsSaved += (_, _) => UpdateSerialSettings();
_hardwareMonitorService.HardwareInformationUpdated += (_, _) => SendInformationToMonitor();
_hardwareMonitorService.HardwareInformationUpdated += SendInformationToMonitor;
}

private void UpdateSerialSettings()
Expand All @@ -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})
Expand Down

0 comments on commit 942c3ca

Please sign in to comment.