From 3685877ab7446bdf4c8a806be65fb30a56e9bdf7 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Fri, 31 Oct 2014 13:31:38 -0700 Subject: [PATCH] Only fire OnConnectionSucceeded if connected --- .../PrinterConnectionAndCommunication.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index 52272cb70..1a3eda79c 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -1339,15 +1339,17 @@ namespace MatterHackers.MatterControl.PrinterCommunication return true; } } - else if (CommunicationState == CommunicationStates.FailedToConnect) - { - connectThread.Join(JoinThreadTimeoutMs); - return false; - } else { - connectThread.Join(JoinThreadTimeoutMs); //Halt connection thread - OnConnectionSucceeded(null); + // If we're no longer in the .AttemptingToConnect state, shutdown the connection thread and fire the + // OnConnectonSuccess event if we're connected + connectThread.Join(JoinThreadTimeoutMs); + + if(PrinterIsConnected) + { + OnConnectionSucceeded(null); + } + return false; } }