@@ -151,8 +151,7 @@ public Task StopAsync(CancellationToken cancellationToken) {
151
151
// Shut down
152
152
_quitting = true ;
153
153
_logger . LogDebug ( "Shutting down..." ) ;
154
- if ( _client . IsConnected )
155
- UpdateTpStateValue ( "RunningState" , "stopped" ) ;
154
+ UpdateTpStateValue ( "RunningState" , "stopped" ) ;
156
155
StopPluginEventsTask ( ) ;
157
156
DisconnectSimConnect ( ) ;
158
157
if ( _pluginConfig . SaveSettings ( ) )
@@ -1022,14 +1021,16 @@ void ConnectSimConnect() {
1022
1021
}
1023
1022
1024
1023
void DisconnectSimConnect ( ) {
1025
- _simAutoConnectDisable . Set ( ) ;
1024
+ bool wasConn = _simConnectService . IsConnected ;
1026
1025
bool wasSet = _simConnectionRequest . IsSet ;
1026
+ _simAutoConnectDisable . Set ( ) ;
1027
1027
_simConnectionRequest . Reset ( ) ;
1028
- if ( _simConnectService . IsConnected )
1028
+ if ( wasConn )
1029
1029
_simConnectService . Disconnect ( ) ;
1030
1030
else if ( wasSet )
1031
1031
_logger . LogInformation ( ( int ) EventIds . PluginInfo , "Connection attempts to Simulator were canceled." ) ;
1032
- UpdateSimConnectState ( ) ;
1032
+ if ( wasConn || wasSet )
1033
+ UpdateSimConnectState ( ) ;
1033
1034
}
1034
1035
1035
1036
// Handles some basic actions like sim connection and repeat rate, with optional data value(s).
@@ -1731,13 +1732,13 @@ public void OnInfoEvent(InfoEvent message) {
1731
1732
"Touch Portal Connected with: TP v{tpV}, SDK v{sdkV}, {pluginId} entry.tp v{plugV}, {plugName} running v{prodV} ({runV})" ,
1732
1733
message . TpVersionString , message . SdkVersion , PluginId , message . PluginVersion , VersionInfo . AssemblyName , VersionInfo . GetProductVersionString ( ) , runtimeVer
1733
1734
) ;
1735
+ UpdateTpStateValue ( "RunningState" , "starting" ) ;
1734
1736
1735
1737
ProcessPluginSettings ( message . Settings ) ;
1736
1738
// convert the entry.tp version back to the actual decimal value
1737
1739
if ( ! uint . TryParse ( $ "{ message . PluginVersion } ", NumberStyles . HexNumber , null , out uint tpVer ) )
1738
1740
tpVer = VersionInfo . GetProductVersionNumber ( ) ;
1739
- // update status & version states
1740
- UpdateTpStateValue ( "RunningState" , "starting" ) ;
1741
+ // update version states
1741
1742
UpdateTpStateValue ( "RunningVersion" , runtimeVer ) ;
1742
1743
UpdateTpStateValue ( "EntryVersion" , $ "{ tpVer : X} ") ;
1743
1744
// set a state for TP config home path (workaround for no env. var access in TP)
0 commit comments