Skip to content

Commit

Permalink
fix: check worker for null on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-welker committed May 16, 2024
1 parent fc14d63 commit 5d190b4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/SonyBraviaDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public SonyBraviaDevice(DeviceConfig config, IBasicCommunication comms)
if (type != eProgramStatusEventType.Stopping)
return;
worker.Abort();
worker?.Abort();
_pollTimer.Stop();
_pollTimer.Dispose();
Expand Down Expand Up @@ -1146,7 +1146,7 @@ public void VolumeUp(bool pressRelease)
_volumeTimer = new CTimer(o => {
var command = _volumeCounter % 2 == 0 ? Rs232Commands.VolumeUp.WithChecksum() : Rs232Commands.VolumeQuery.WithChecksum();
_lastCommand = command;
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Sending Volume up command {command}", this, ComTextHelper.GetEscapedText(command));
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, _volumeCounter % 2 == 0 ? "Sending Volume Up command {command}" : "Sending Volume Query command {command}", this, ComTextHelper.GetEscapedText(command));
_coms.SendBytes(command);
_volumeCounter += 1;
}, null, 0, 500);
Expand Down Expand Up @@ -1183,7 +1183,7 @@ public void VolumeDown(bool pressRelease)
_volumeTimer = new CTimer(o => {
var command = _volumeCounter % 2 == 0 ? Rs232Commands.VolumeDown.WithChecksum() : Rs232Commands.VolumeQuery.WithChecksum();
_lastCommand = command;
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Sending Volume up command {command}", this, ComTextHelper.GetEscapedText(command));
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, _volumeCounter % 2 == 0 ? "Sending Volume Down command {command}" : "Sending Volume Query command {command}", this, ComTextHelper.GetEscapedText(command));
_coms.SendBytes(command);
_volumeCounter += 1;
}, null, 0, 500);
Expand Down

0 comments on commit 5d190b4

Please sign in to comment.