From 47d7120b81dd646ed9b18740c9cc87a7a33a7c58 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 27 Dec 2017 16:22:17 +0200 Subject: Implemented KeepAlive Mechanism. Direct Synchronization is now working good. --- .../DefaultStudioApplicationManager.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index b0315e633..336681801 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -33,7 +33,27 @@ namespace Tango.MachineStudio.UI.StudioApplication public IExternalBridgeClient ConnectedMachine { get { return _connectedMachine; } - set { _connectedMachine = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(IsMachineConnected)); } + set + { + _connectedMachine = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged(nameof(IsMachineConnected)); + + if (_connectedMachine != null) + { + _connectedMachine.StateChanged -= ConnectedMachine_StateChanged; + _connectedMachine.StateChanged += ConnectedMachine_StateChanged; + } + } + } + + private void ConnectedMachine_StateChanged(object sender, Transport.TransportComponentState e) + { + if (e == Transport.TransportComponentState.Disconnected || e == Transport.TransportComponentState.Failed) + { + ConnectedMachine = null; + } + } public bool IsMachineConnected -- cgit v1.3.1