Esempio n. 1
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_timerThread != null)
            {
                _stopTimerEvent.Set();
                _timerThread = null;
            }

            try
            {
                if (_inputDevice.IsReceiving)
                {
                    _inputDevice.StopReceiving();
                }

                if (_inputDevice.IsOpen)
                {
                    _inputDevice.Close();
                }
            }
            catch (Exception e)
            {
                Log.Error(e, "Exception while trying to stop and close input device");
            }

            _inputDevice.Nrpn          -= InputDeviceOnNrpn;
            _inputDevice.ControlChange -= InputDeviceOnControlChange;

            _disposed = true;
        }
Esempio n. 2
0
 public static void Disconnect()
 {
     if (midiKeyboard == null)
     {
         return;
     }
     if (midiKeyboard.IsOpen == true)
     {
         try
         {
             midiKeyboard.StopReceiving();
             midiKeyboard.Close();
             midiKeyboard.RemoveAllEventHandlers();
         }
         catch (Exception e)
         {
             MessageBox.Show($"断开错误 \r\n {e.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }