示例#1
0
 /// <summary>
 /// The constructor.
 /// Just save the input model as this's model.
 /// Do not add the properties' paths, since they are not receivable.
 /// Add the model a delegate function that handles disconnection.
 /// </summary>
 /// <param name="model"> The VM's model. </param>
 public ControllersPanelVM(IFlightGearCommunicator model)
 {
     this.model = model;
     this.model.DisconnectionOccurred +=
         delegate()
     {
         DisconnectionOccurred?.Invoke();
     };
 }
示例#2
0
        /// <summary>
        /// Disconnect from the server.
        /// </summary>
        public void Disconnect()
        {
            stopMutex.WaitOne();
            stop = true;
            stopMutex.ReleaseMutex();

            try
            {
                /* If there is a condition race give up, as if you don't you might not be connected to any server
                 * but stop stays false.*/
                stopMutex.WaitOne(0);
                this.telnetClient.Disconnect();
                // Notify about the disconnection.
                DisconnectionOccurred?.Invoke();
            }
            finally
            {
                stopMutex.ReleaseMutex();
            }
        }