Exemplo n.º 1
0
        public void CloseConnection()
        {
            try
            {
                if (simconnect != null)
                {
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.SIM_START);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.SIM_STOP);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.PAUSED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.AIRCRAFT_LOADED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.FLIGHT_LOADED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.CRASHED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.CRASH_RESET);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.FLIGHTPLAN_ACTIVATED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.FLIGHTPLAN_DEACTIVATED);
                    simconnect.UnsubscribeFromSystemEvent(EVENTS.POSITION_CHANGED);
                    simconnect.UnsubscribeToFacilities(SIMCONNECT_FACILITY_LIST_TYPE.AIRPORT);

                    // Dispose serves the same purpose as SimConnect_Close()
                    simconnect.Dispose();
                    simconnect = null;
                }
            }
            catch (Exception ex)
            {
                logger.LogWarning($"Cannot unsubscribe events! Error: {ex.Message}");
            }
        }
Exemplo n.º 2
0
        private void closeConnection()
        {
            if (simconnect != null)
            {
                // Unsubscribe from all the system events
                simconnect.UnsubscribeFromSystemEvent(EVENTS.SIMSTART);
                simconnect.UnsubscribeFromSystemEvent(EVENTS.SIMSTOP);

                // Dispose serves the same purpose as SimConnect_Close()
                simconnect.Dispose();
                simconnect = null;
            }
        }
Exemplo n.º 3
0
 public void DisconnectSim()
 {
     if (simconnect != null)
     {
         OnFSConnectionStatusChanged(false);
         if (!simExited)
         {
             simconnect.UnsubscribeFromSystemEvent(EVENTS.SIM_START);
             simconnect.UnsubscribeFromSystemEvent(EVENTS.SIM_STOP);
             simconnect.UnsubscribeFromSystemEvent(EVENTS.FLIGHTPLAN_LOADED);
             simconnect.UnsubscribeFromSystemEvent(EVENTS.FLIGHTPLAN_DIACTIVATED);
         }
         simconnect.Dispose();
         simconnect = null;
     }
     SimConnected = false;
 }
Exemplo n.º 4
0
 public void disconnect()
 {
     if (simconnect != null)
     {
         simconnect.UnsubscribeFromSystemEvent(EVENTS.EVENT_1S);
         simconnect.Dispose();
         simconnect = null;
     }
     FSXConnectionChanged();
 }
Exemplo n.º 5
0
 //release our simconnect object
 private void closeFocusGrab()
 {
     if (simconnect != null)
     {
         try //The application may have been shut down and this will throw
         {
             simconnect.UnsubscribeFromSystemEvent(Event.MISSION_END);
             simconnect.Dispose();
         }
         catch  //do nothing here we are closing simconnect after this.
         {}
         simconnect = null;
     }
 }