private void connectToEventEndpoint()
 {
     try
     {
         if (_eventendpoint != null && _eventendpoint.IsConnected)
         {
             return;
         }
         var instance = new InstanceLocator("OpenIDE.Events").GetInstance(_path);
         if (instance == null)
         {
             return;
         }
         _eventendpoint = new SocketClient();
         _eventendpoint.IncomingMessage += Handle_eventIncomingMessage;
         _eventendpoint.Connect(instance.Port);
         if (_eventendpoint.IsConnected)
         {
             startBackgroundShutdownHandler();
             return;
         }
         _bus.Publish(new ExternalCommandMessage("EditorEngine", "shutdown"));
     }
     catch (Exception ex)
     {
         Debug.WriteError(ex.ToString());
     }
 }
 private bool isConnected()
 {
     try
     {
         if (_client != null && _client.IsConnected)
         {
             return(true);
         }
         var instance = new InstanceLocator("EditorEngine").GetInstance(_path);
         if (instance == null)
         {
             return(false);
         }
         _client = new SocketClient();
         _client.IncomingMessage += Handle_clientIncomingMessage;
         _client.Connect(instance.Port);
         if (_client.IsConnected)
         {
             startBackgroundShutdownHandler();
             return(true);
         }
         _client = null;
         return(false);
     }
     catch (Exception ex)
     {
         Debug.WriteError(ex.ToString());
         return(false);
     }
 }