fix: register ComPort shutdown hook after initialization

This commit is contained in:
copilot-swe-agent[bot] 2026-06-09 17:11:18 +00:00 committed by GitHub
parent cd8bfcfbdc
commit d4f1fecc64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,6 @@ namespace PepperDash.Essentials.Core
ComPort.ComPortSpec spec, EssentialsControlPropertiesConfig config) : base(key) ComPort.ComPortSpec spec, EssentialsControlPropertiesConfig config) : base(key)
{ {
StreamDebugging = new CommunicationStreamDebugging(key); StreamDebugging = new CommunicationStreamDebugging(key);
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
Spec = spec; Spec = spec;
@ -62,6 +61,8 @@ namespace PepperDash.Essentials.Core
RegisterAndConfigureComPort(); RegisterAndConfigureComPort();
}); });
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
} }
/// <summary> /// <summary>
@ -73,8 +74,6 @@ namespace PepperDash.Essentials.Core
public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec) public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec)
: base(key) : base(key)
{ {
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
if (port == null) if (port == null)
{ {
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function"); Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function");
@ -86,6 +85,7 @@ namespace PepperDash.Essentials.Core
//IsConnected = new BoolFeedback(CommonBoolCue.IsConnected, () => true); //IsConnected = new BoolFeedback(CommonBoolCue.IsConnected, () => true);
RegisterAndConfigureComPort(); RegisterAndConfigureComPort();
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
} }
private void RegisterAndConfigureComPort() private void RegisterAndConfigureComPort()