StopReceiving() public method

Stops this input device from receiving messages.

This method waits for all in-progress input event handlers to finish, and then joins (shuts down) the background thread that was created in StartReceiving. Thus, when this function returns you can be sure that no more event handlers will be invoked.

It is illegal to call this method from an input event handler (ie, from the background thread), and doing so throws an exception. If an event handler really needs to call this method, consider using BeginInvoke to schedule it on another thread.

The device is not open; is not receiving; /// or called from within an event handler (ie, from the background thread). The device cannot start receiving.
public StopReceiving ( ) : void
return void
Esempio n. 1
0
        private void MainWindow_OnClosed(object sender, EventArgs e)
        {
            _midiDevice.StopReceiving();
            _midiDevice.Close();

            _serialPort.Close();
        }
        private void MidiActive(object sender, RoutedEventArgs e)
        {
            if ((sender as CheckBox).IsChecked ?? false)
            {
                if (inputDevices.SelectedIndex == -1)
                {
                    return;
                }

                d                = Midi.InputDevice.InstalledDevices[inputDevices.SelectedIndex];
                d.NoteOn        += D_NoteOn;
                d.NoteOff       += D_NoteOff;
                d.ProgramChange += D_ProgramChange;
                d.ControlChange += D_ControlChange;
                if (!d.IsOpen)
                {
                    d.Open();
                }
                d.StartReceiving(null);
            }
            else
            {
                d.StopReceiving();
                d.Close();
            }
        }
 private void CloseMidiDevice(Midi.InputDevice _InputDevice)
 {
     _InputDevice.StopReceiving();
     _InputDevice.ControlChange -= NoteCC;
     _InputDevice.Close();
 }